~netlandish/django-wiki

60c0589f41c4d4b9d9b6df0a7078315397909eb5 — Benjamin Bach 6 years ago 122d38b + 6309de6
Merge pull request #894 from Mortal/txbug

Add tests for buggy translation behavior
2 files changed, 32 insertions(+), 0 deletions(-)

M tests/core/test_views.py
M tests/plugins/globalhistory/test_globalhistory.py
M tests/core/test_views.py => tests/core/test_views.py +18 -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,23 @@ 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)
            self.assertNotIn('Be careful', response_da.rendered_content)


class DeleteViewTest(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):


M tests/plugins/globalhistory/test_globalhistory.py => tests/plugins/globalhistory/test_globalhistory.py +14 -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,16 @@ 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)
            self.assertNotIn('in the wiki', response_da.rendered_content)