Fix tests on django CMS 3.0
This commit is contained in:
parent
70cab57ef8
commit
9d168f6f45
4 changed files with 25 additions and 15 deletions
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, print_function, unicode_literals
|
from __future__ import absolute_import, print_function, unicode_literals
|
||||||
|
|
||||||
import copy
|
|
||||||
from aldryn_apphooks_config.utils import get_app_instance
|
from aldryn_apphooks_config.utils import get_app_instance
|
||||||
|
|
||||||
from django.utils.translation import activate
|
from django.utils.translation import activate
|
||||||
|
|
|
@ -137,7 +137,6 @@ class AdminTest(BaseTest):
|
||||||
msg_mid.process_request(request)
|
msg_mid.process_request(request)
|
||||||
post_admin = admin.site._registry[Post]
|
post_admin = admin.site._registry[Post]
|
||||||
response = post_admin.edit_field(request, post.pk, 'en')
|
response = post_admin.edit_field(request, post.pk, 'en')
|
||||||
#print(response.content.decode('utf-8'))
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
modified_post = Post.objects.language('en').get(pk=post.pk)
|
modified_post = Post.objects.language('en').get(pk=post.pk)
|
||||||
self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text'])
|
self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text'])
|
||||||
|
@ -171,7 +170,11 @@ class ModelsTest(BaseTest):
|
||||||
'month': '%02d' % post.date_published.month,
|
'month': '%02d' % post.date_published.month,
|
||||||
'day': '%02d' % post.date_published.day,
|
'day': '%02d' % post.date_published.day,
|
||||||
'slug': post.safe_translation_getter('slug', any_language=get_language())}
|
'slug': post.safe_translation_getter('slug', any_language=get_language())}
|
||||||
url_en = reverse('djangocms_blog:post-detail', kwargs=kwargs)
|
url_en = reverse(
|
||||||
|
'%s:post-detail' % self.app_config_1.namespace,
|
||||||
|
kwargs=kwargs,
|
||||||
|
current_app=self.app_config_1
|
||||||
|
)
|
||||||
self.assertEqual(url_en, post.get_absolute_url())
|
self.assertEqual(url_en, post.get_absolute_url())
|
||||||
|
|
||||||
with override('it'):
|
with override('it'):
|
||||||
|
@ -180,7 +183,11 @@ class ModelsTest(BaseTest):
|
||||||
'month': '%02d' % post.date_published.month,
|
'month': '%02d' % post.date_published.month,
|
||||||
'day': '%02d' % post.date_published.day,
|
'day': '%02d' % post.date_published.day,
|
||||||
'slug': post.safe_translation_getter('slug', any_language=get_language())}
|
'slug': post.safe_translation_getter('slug', any_language=get_language())}
|
||||||
url_it = reverse('djangocms_blog:post-detail', kwargs=kwargs)
|
url_it = reverse(
|
||||||
|
'%s:post-detail' % self.app_config_1.namespace,
|
||||||
|
kwargs=kwargs,
|
||||||
|
current_app=self.app_config_1
|
||||||
|
)
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -255,19 +255,24 @@ class ViewTest(BaseTest):
|
||||||
self.assertEqual(context['post_list'][0].title, 'Second post')
|
self.assertEqual(context['post_list'][0].title, 'Second post')
|
||||||
|
|
||||||
def test_feed(self):
|
def test_feed(self):
|
||||||
pages = self.get_pages()
|
|
||||||
posts = self.get_posts()
|
posts = self.get_posts()
|
||||||
|
pages = self.get_pages()
|
||||||
posts[0].tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4')
|
posts[0].tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4')
|
||||||
posts[0].save()
|
posts[0].save()
|
||||||
posts[1].tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8')
|
posts[1].tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8')
|
||||||
posts[1].save()
|
posts[1].save()
|
||||||
posts[0].set_current_language('en')
|
posts[0].set_current_language('en')
|
||||||
|
|
||||||
|
with smart_override('en'):
|
||||||
|
with switch_language(posts[0], 'en'):
|
||||||
|
|
||||||
|
request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url())
|
||||||
|
|
||||||
feed = LatestEntriesFeed()
|
feed = LatestEntriesFeed()
|
||||||
feed.namespace = self.app_config_1.namespace
|
feed.namespace = self.app_config_1.namespace
|
||||||
feed.config = self.app_config_1
|
feed.config = self.app_config_1
|
||||||
self.assertEqual(list(feed.items()), [posts[0]])
|
self.assertEqual(list(feed.items()), [posts[0]])
|
||||||
request = self.get_page_request(pages[1], self.user, lang='en', edit=False)
|
self.reload_urlconf()
|
||||||
xml = feed(request)
|
xml = feed(request)
|
||||||
self.assertContains(xml, posts[0].get_absolute_url())
|
self.assertContains(xml, posts[0].get_absolute_url())
|
||||||
self.assertContains(xml, 'Blog articles on example.com')
|
self.assertContains(xml, 'Blog articles on example.com')
|
||||||
|
@ -278,7 +283,7 @@ class ViewTest(BaseTest):
|
||||||
feed.namespace = self.app_config_1.namespace
|
feed.namespace = self.app_config_1.namespace
|
||||||
feed.config = self.app_config_1
|
feed.config = self.app_config_1
|
||||||
self.assertEqual(list(feed.items()), [posts[0]])
|
self.assertEqual(list(feed.items()), [posts[0]])
|
||||||
request = self.get_page_request(pages[1], self.user, lang='en', edit=False)
|
request = self.get_page_request(pages[1], self.user, path=posts[0].get_absolute_url())
|
||||||
xml = feed(request)
|
xml = feed(request)
|
||||||
self.assertContains(xml, posts[0].get_absolute_url())
|
self.assertContains(xml, posts[0].get_absolute_url())
|
||||||
self.assertContains(xml, 'Articoli del blog su example.com')
|
self.assertContains(xml, 'Articoli del blog su example.com')
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -7,7 +7,6 @@ deps =
|
||||||
django16: Django>=1.6,<1.7
|
django16: Django>=1.6,<1.7
|
||||||
django17: Django>=1.7,<1.8
|
django17: Django>=1.7,<1.8
|
||||||
django18: Django>=1.7,<1.9
|
django18: Django>=1.7,<1.9
|
||||||
django18: https://github.com/stefanfoulis/django-filer/archive/develop.zip
|
|
||||||
cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip
|
cms30: https://github.com/divio/django-cms/archive/support/3.0.x.zip
|
||||||
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
|
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
|
||||||
cms32: https://github.com/divio/django-cms/archive/develop.zip
|
cms32: https://github.com/divio/django-cms/archive/develop.zip
|
||||||
|
|
Loading…
Reference in a new issue