Skip to content

Commit

Permalink
Add a small test for tabbed translation admin
Browse files Browse the repository at this point in the history
  • Loading branch information
julianwachholz committed Jun 14, 2024
1 parent bf5d3fb commit ffac13e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 7 additions & 2 deletions tests/app/admin.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
14 changes: 13 additions & 1 deletion tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")

0 comments on commit ffac13e

Please sign in to comment.