diff --git a/HISTORY.rst b/HISTORY.rst index b2cfb9a..5149e65 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ History ++++++++++++++++++ * Make categories non required +* Fix tests with parler>=1.6 0.6.3 (2015-12-22) ++++++++++++++++++ diff --git a/requirements-test.txt b/requirements-test.txt index 94e66fe..a9c6ae7 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -9,3 +9,4 @@ https://github.com/nephila/djangocms-helper/archive/develop.zip tox>=2.0 wheel pysolr +django-parler>=1.6 diff --git a/tests/base.py b/tests/base.py index 6442506..cb6e3f3 100644 --- a/tests/base.py +++ b/tests/base.py @@ -6,6 +6,7 @@ from copy import deepcopy from cmsplugin_filer_image.models import ThumbnailOption from django.contrib.auth import get_user_model from django.contrib.sites.models import Site +from django.core.cache import cache from djangocms_helper.base_test import BaseTestCase from haystack import connections from haystack.constants import DEFAULT_ALIAS @@ -18,7 +19,7 @@ User = get_user_model() def _get_cat_pk(lang, name): - return lambda: BlogCategory.objects.translated(lang, name=name).get().pk + return lambda: BlogCategory.objects.language(lang).translated(lang, name=name).get().pk class BaseTest(BaseTestCase): @@ -65,7 +66,8 @@ class BaseTest(BaseTestCase): 'description': 'Descrizione del terzo post', 'keywords': 'keyword5, keyword6', 'text': 'Testo del terzo post'}, }, - {'en': {'title': 'Different appconfig', 'abstract': '
Different appconfig first line
', + {'en': {'title': 'Different appconfig', + 'abstract': 'Different appconfig first line
', 'description': 'Different appconfig description', 'keywords': 'keyword5, keyword6', 'text': 'Different appconfig text', 'app_config': 'sample_app2', 'publish': True}, 'it': {'title': 'Altro appconfig', 'abstract': 'prima riga del Altro appconfig
', @@ -84,17 +86,19 @@ class BaseTest(BaseTestCase): {'en': {'name': 'Almost', 'app_config': 'sample_app'}, 'it': {'name': 'Mezzo'}, }, - {'en': {'name': 'Loud', 'parent_id': _get_cat_pk('en', 'Almost'), 'app_config': 'sample_app'}, - 'it': {'name': 'Forte', 'parent_id': _get_cat_pk('it', 'Mezzo')}, - }, - {'en': {'name': 'Silent', 'parent_id': _get_cat_pk('en', 'Almost'), 'app_config': 'sample_app'}, - }, {'en': {'name': 'Drums', 'app_config': 'sample_app2'}, 'it': {'name': 'Tamburi'}, }, {'en': {'name': 'Guitars', 'app_config': 'sample_app2'}, 'it': {'name': 'Chitarre'}, }, + {'en': {'name': 'Loud', 'parent_id': _get_cat_pk('en', 'Almost'), + 'app_config': 'sample_app'}, + 'it': {'name': 'Forte', 'parent_id': _get_cat_pk('it', 'Mezzo')}, + }, + {'en': {'name': 'Silent', 'parent_id': _get_cat_pk('en', 'Almost'), + 'app_config': 'sample_app'}, + }, ) @classmethod @@ -120,11 +124,13 @@ class BaseTest(BaseTestCase): 'sample_app': cls.app_config_1, 'sample_app2': cls.app_config_2, } - cls.category_1 = BlogCategory.objects.create(name='category 1', app_config=cls.app_config_1) + cls.category_1 = BlogCategory.objects.create(name='category 1', + app_config=cls.app_config_1) cls.category_1.set_current_language('it', initialize=True) cls.category_1.name = 'categoria 1' cls.category_1.save() cls.site_2 = Site.objects.create(domain='http://example2.com', name='example 2') + cache.clear() @classmethod def tearDownClass(cls): @@ -168,7 +174,6 @@ class BaseTest(BaseTestCase): meta_description=data['description'], meta_keywords=data['keywords'] ) - post = self.reload_model(post) post.categories.add(self.category_1) if sites: for site in sites: @@ -177,6 +182,7 @@ class BaseTest(BaseTestCase): def get_posts(self, sites=None): posts = [] + cache.clear() for post in self._post_data: post1 = self._get_post(post['en'], sites=sites) post1 = self._get_post(post['it'], post=post1, lang='it') diff --git a/tests/test_menu.py b/tests/test_menu.py index 979709c..0f9f046 100644 --- a/tests/test_menu.py +++ b/tests/test_menu.py @@ -21,6 +21,7 @@ class MenuTest(BaseTest): def setUp(self): super(MenuTest, self).setUp() self.cats = [self.category_1] + cache.clear() for i, lang_data in enumerate(self._categories_data): cat = self._get_category(lang_data['en']) if 'it' in lang_data: diff --git a/tox.ini b/tox.ini index 0ed8921..8d74cd1 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,6 @@ deps = https://github.com/nephila/django-meta-mixin/archive/master.zip https://github.com/nephila/djangocms-helper/archive/develop.zip py26: unittest2 - django-parler<1.5 django-mptt<0.8 https://github.com/aldryn/aldryn-apphooks-config/archive/master.zip https://github.com/nephila/djangocms-apphook-setup/archive/master.zip