Fix language tests
This commit is contained in:
parent
28027940a1
commit
43f2c9ac36
1 changed files with 20 additions and 16 deletions
|
@ -5,6 +5,7 @@ from cms.utils.plugins import downcast_plugins
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
|
from django.utils.translation import get_language, activate, override
|
||||||
import parler
|
import parler
|
||||||
from taggit.models import Tag
|
from taggit.models import Tag
|
||||||
|
|
||||||
|
@ -37,18 +38,21 @@ class ModelsTest(BaseTest):
|
||||||
self.assertNotEqual(meta_it.title, meta_en.title)
|
self.assertNotEqual(meta_it.title, meta_en.title)
|
||||||
self.assertEqual(meta_it.description, post.meta_description)
|
self.assertEqual(meta_it.description, post.meta_description)
|
||||||
|
|
||||||
post.set_current_language('en')
|
with override('en'):
|
||||||
|
post.set_current_language(get_language())
|
||||||
kwargs = {'year': post.date_published.year,
|
kwargs = {'year': post.date_published.year,
|
||||||
'month': post.date_published.month,
|
'month': '%02d' % post.date_published.month,
|
||||||
'day': post.date_published.day,
|
'day': '%02d' % post.date_published.day,
|
||||||
'slug': post.safe_translation_getter('slug', any_language=True)}
|
'slug': post.safe_translation_getter('slug', any_language=get_language())}
|
||||||
url_en = reverse('djangocms_blog:post-detail', kwargs=kwargs)
|
url_en = reverse('djangocms_blog:post-detail', kwargs=kwargs)
|
||||||
self.assertEqual(url_en, post.get_absolute_url())
|
self.assertEqual(url_en, post.get_absolute_url())
|
||||||
post.set_current_language('it')
|
|
||||||
|
with override('it'):
|
||||||
|
post.set_current_language(get_language())
|
||||||
kwargs = {'year': post.date_published.year,
|
kwargs = {'year': post.date_published.year,
|
||||||
'month': post.date_published.month,
|
'month': '%02d' % post.date_published.month,
|
||||||
'day': post.date_published.day,
|
'day': '%02d' % post.date_published.day,
|
||||||
'slug': post.safe_translation_getter('slug', any_language=True)}
|
'slug': post.safe_translation_getter('slug', any_language=get_language())}
|
||||||
url_it = reverse('djangocms_blog:post-detail', kwargs=kwargs)
|
url_it = reverse('djangocms_blog:post-detail', kwargs=kwargs)
|
||||||
self.assertEqual(url_it, post.get_absolute_url())
|
self.assertEqual(url_it, post.get_absolute_url())
|
||||||
self.assertNotEqual(url_it, url_en)
|
self.assertNotEqual(url_it, url_en)
|
||||||
|
|
Loading…
Reference in a new issue