From b970bedaf97f668a993e195f6dc09da9999f8445 Mon Sep 17 00:00:00 2001 From: Mathias Rav Date: Mon, 30 Jul 2018 12:24:11 +0200 Subject: [PATCH] Add tests for buggy translation behavior django-wiki contains two instances of {% blocktrans %}...{% plural %}...{% endblocktrans %} and the translations of these blocks are not in use for some reason. --- tests/core/test_views.py | 20 +++++++++++++++++++ .../globalhistory/test_globalhistory.py | 16 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/tests/core/test_views.py b/tests/core/test_views.py index 7585f875..4c596ef3 100644 --- a/tests/core/test_views.py +++ b/tests/core/test_views.py @@ -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): diff --git a/tests/plugins/globalhistory/test_globalhistory.py b/tests/plugins/globalhistory/test_globalhistory.py index a902584c..72d31766 100644 --- a/tests/plugins/globalhistory/test_globalhistory.py +++ b/tests/plugins/globalhistory/test_globalhistory.py @@ -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) -- 2.45.2