M tests/core/test_views.py => tests/core/test_views.py +20 -0
@@ 2,6 2,7 @@ import pprint
from django.http import JsonResponse
from django.shortcuts import resolve_url
+from django.utils import translation
from django.utils.html import escape
from django_functest import FuncBaseMixin
from wiki import models
@@ 285,6 286,25 @@ class MoveViewTest(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTes
urldst = URLPath.get_by_path('/test1new/test020/')
self.assertEqual(urlsrc.moved_to, urldst)
+ def test_translation(self):
+ # Test that translation of "Be careful, links to this article" exists.
+ self.client.post(
+ resolve_url('wiki:create', path=''),
+ {'title': 'Test', 'slug': 'test0', 'content': 'Content'}
+ )
+ url = resolve_url('wiki:move', path='test0/')
+ response_en = self.client.get(url)
+ self.assertIn('Move article', response_en.rendered_content)
+ self.assertIn('Be careful', response_en.rendered_content)
+
+ with translation.override('da-DK'):
+ response_da = self.client.get(url)
+
+ self.assertNotIn('Move article', response_da.rendered_content)
+
+ # TODO: Fix this bug and change to assertNotIn.
+ self.assertIn('Be careful', response_da.rendered_content)
+
class DeleteViewTest(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):
M tests/plugins/globalhistory/test_globalhistory.py => tests/plugins/globalhistory/test_globalhistory.py +16 -0
@@ 1,4 1,5 @@
from django.urls import reverse
+from django.utils import translation
from wiki.models import URLPath
from ...base import ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin
@@ 77,3 78,18 @@ class GlobalhistoryTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoCli
)
response = self.client.get(url1)
self.assertRegexpMatches(response.rendered_content, expected)
+
+ def test_translation(self):
+ # Test that translation of "List of %s changes in the wiki." exists.
+ url = reverse('wiki:globalhistory')
+ response_en = self.client.get(url)
+ self.assertIn('Global history', response_en.rendered_content)
+ self.assertIn('in the wiki', response_en.rendered_content)
+
+ with translation.override('da-DK'):
+ response_da = self.client.get(url)
+
+ self.assertNotIn('Global history', response_da.rendered_content)
+
+ # TODO: Fix this bug and change to assertNotIn.
+ self.assertIn('in the wiki', response_da.rendered_content)