From ffac13eb8bb87a759a6a335b94cac7a041042db7 Mon Sep 17 00:00:00 2001 From: Julian Wachholz Date: Fri, 14 Jun 2024 20:01:15 +0200 Subject: [PATCH] Add a small test for tabbed translation admin --- tests/app/admin.py | 9 +++++++-- tests/test_admin.py | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/app/admin.py b/tests/app/admin.py index 5555879..10395b1 100644 --- a/tests/app/admin.py +++ b/tests/app/admin.py @@ -1,8 +1,8 @@ from django.contrib import admin -from modeltrans.admin import ActiveLanguageMixin +from modeltrans.admin import ActiveLanguageMixin, TabbedLanguageMixin -from .models import Blog, Category, Site +from .models import Blog, Category, Post, Site @admin.register(Blog) @@ -19,3 +19,8 @@ class CategoryAdmin(ActiveLanguageMixin, admin.ModelAdmin): @admin.register(Site) class SiteAdmin(ActiveLanguageMixin, admin.ModelAdmin): pass + + +@admin.register(Post) +class PostAdmin(TabbedLanguageMixin, admin.ModelAdmin): + pass diff --git a/tests/test_admin.py b/tests/test_admin.py index b8a75d0..3297142 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -3,7 +3,7 @@ from django.urls import reverse from django.utils.translation import override -from .app.models import Category, Site +from .app.models import Category, Post, Site from .utils import load_wiki User = get_user_model() @@ -66,3 +66,15 @@ def url(q): response = self.client.get(url("frog")) self.assertContains(response, "Frog") + + def test_tabbed_admin(self): + post = Post.objects.create( + title="History of the Universe", + title_nl="Geschiedenis van het heelal", + ) + url = reverse("admin:app_post_change", args=(post.pk,)) + response = self.client.get(url) + + self.assertEqual(response.status_code, 200) + self.assertContains(response, "History of the Universe") + self.assertContains(response, "Geschiedenis van het heelal")