Fix tests for issues discovered when testing with knocker
This commit is contained in:
parent
0e07f9a850
commit
4503a14b4f
5 changed files with 30 additions and 21 deletions
|
@ -90,7 +90,7 @@ HELPER_SETTINGS = dict(
|
|||
FILE_UPLOAD_TEMP_DIR=mkdtemp(),
|
||||
SITE_ID=1,
|
||||
HAYSTACK_CONNECTIONS={
|
||||
"default": {}
|
||||
'default': {}
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -133,5 +133,5 @@ def run():
|
|||
from djangocms_helper import runner
|
||||
runner.cms('djangocms_blog')
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
|
3
setup.py
3
setup.py
|
@ -36,8 +36,7 @@ setup(
|
|||
'django-taggit-autosuggest',
|
||||
'djangocms-text-ckeditor',
|
||||
'cmsplugin-filer',
|
||||
'django-meta>=0.2',
|
||||
'django-meta-mixin>=0.2.1',
|
||||
'django-meta>=1.1',
|
||||
'aldryn-apphooks-config>=0.2.6',
|
||||
'djangocms-apphook-setup',
|
||||
'aldryn-search'
|
||||
|
|
|
@ -40,8 +40,8 @@ class MenuTest(BaseTest):
|
|||
"""
|
||||
Tests if all categories are present in the menu
|
||||
"""
|
||||
posts = self.get_posts()
|
||||
pages = self.get_pages()
|
||||
posts = self.get_posts()
|
||||
self.reload_urlconf()
|
||||
|
||||
for lang in ('en', 'it'):
|
||||
|
@ -66,8 +66,8 @@ class MenuTest(BaseTest):
|
|||
"""
|
||||
Tests menu structure based on menu_structure configuration
|
||||
"""
|
||||
posts = self.get_posts()
|
||||
self.get_pages()
|
||||
posts = self.get_posts()
|
||||
|
||||
cats_url = {}
|
||||
posts_url = {}
|
||||
|
@ -77,7 +77,7 @@ class MenuTest(BaseTest):
|
|||
for lang in languages:
|
||||
with smart_override(lang):
|
||||
cats_url[lang] = set([cat.get_absolute_url() for cat in self.cats if cat.has_translation(lang)])
|
||||
posts_url[lang] = set([post.get_absolute_url() for post in posts if post.has_translation(lang) and post.app_config == self.app_config_1])
|
||||
posts_url[lang] = set([post.get_absolute_url(lang) for post in posts if post.has_translation(lang) and post.app_config == self.app_config_1])
|
||||
|
||||
# No item in the menu
|
||||
self.app_config_1.app_data.config.menu_structure = MENU_TYPE_NONE
|
||||
|
@ -132,8 +132,8 @@ class MenuTest(BaseTest):
|
|||
Tests if correct category is selected in the menu
|
||||
according to context (view object)
|
||||
"""
|
||||
posts = self.get_posts()
|
||||
pages = self.get_pages()
|
||||
posts = self.get_posts()
|
||||
|
||||
tests = (
|
||||
# view class, view kwarg, view object, category
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import re
|
||||
from contextlib import contextmanager
|
||||
from copy import deepcopy
|
||||
from datetime import timedelta
|
||||
|
||||
|
@ -33,6 +34,13 @@ try:
|
|||
except ImportError:
|
||||
from django.utils.unittest import SkipTest
|
||||
|
||||
try:
|
||||
from knocker.signals import pause_knocks
|
||||
except ImportError:
|
||||
@contextmanager
|
||||
def pause_knocks(obj):
|
||||
yield
|
||||
|
||||
|
||||
class AdminTest(BaseTest):
|
||||
|
||||
|
@ -242,17 +250,18 @@ class AdminTest(BaseTest):
|
|||
pages = self.get_pages()
|
||||
post = self._get_post(self._post_data[0]['en'])
|
||||
|
||||
with self.login_user_context(self.user):
|
||||
with self.settings(BLOG_USE_PLACEHOLDER=False):
|
||||
data = {'post_text': 'ehi text', 'title': 'some title'}
|
||||
request = self.post_request(pages[0], 'en', user=self.user, data=data, path='/en/?edit_fields=post_text')
|
||||
msg_mid = MessageMiddleware()
|
||||
msg_mid.process_request(request)
|
||||
post_admin = admin.site._registry[Post]
|
||||
response = post_admin.edit_field(request, post.pk, 'en')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
modified_post = Post.objects.language('en').get(pk=post.pk)
|
||||
self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text'])
|
||||
with pause_knocks(post):
|
||||
with self.login_user_context(self.user):
|
||||
with self.settings(BLOG_USE_PLACEHOLDER=False):
|
||||
data = {'post_text': 'ehi text', 'title': 'some title'}
|
||||
request = self.post_request(pages[0], 'en', user=self.user, data=data, path='/en/?edit_fields=post_text')
|
||||
msg_mid = MessageMiddleware()
|
||||
msg_mid.process_request(request)
|
||||
post_admin = admin.site._registry[Post]
|
||||
response = post_admin.edit_field(request, post.pk, 'en')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
modified_post = Post.objects.language('en').get(pk=post.pk)
|
||||
self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text'])
|
||||
|
||||
|
||||
class ModelsTest(BaseTest):
|
||||
|
@ -422,6 +431,7 @@ class ModelsTest(BaseTest):
|
|||
self.assertTrue(re.match(r'.*/%s/$' % post.slug, post.get_absolute_url()))
|
||||
|
||||
def test_manager(self):
|
||||
self.get_pages()
|
||||
post1 = self._get_post(self._post_data[0]['en'])
|
||||
post2 = self._get_post(self._post_data[1]['en'])
|
||||
|
||||
|
@ -601,6 +611,7 @@ class ModelsTest(BaseTest):
|
|||
self.assertEqual(set(list(Post.objects.all().on_site())), set([post2, post3]))
|
||||
|
||||
def test_str_repr(self):
|
||||
self.get_pages()
|
||||
post1 = self._get_post(self._post_data[0]['en'])
|
||||
post1.meta_description = ''
|
||||
post1.main_image = None
|
||||
|
|
3
tox.ini
3
tox.ini
|
@ -19,8 +19,7 @@ deps =
|
|||
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
|
||||
cms32: https://github.com/divio/django-cms/archive/release/3.2.x.zip
|
||||
knocker: https://github.com/divio/django-cms/archive/release/3.2.x.zip
|
||||
knocker: https://github.com/nephila/django-knocker/archive/master.zip
|
||||
https://github.com/nephila/django-meta-mixin/archive/develop.zip
|
||||
knocker: https://github.com/nephila/django-knocker/archive/master.zip?0.1.1
|
||||
django-meta>=1.0b3
|
||||
https://github.com/nephila/djangocms-helper/archive/develop.zip
|
||||
py26: unittest2
|
||||
|
|
Loading…
Reference in a new issue