Fix tests on django CMS 3.0

This commit is contained in:
Iacopo Spalletti 2015-09-06 19:34:20 +02:00
parent 70cab57ef8
commit 9d168f6f45
4 changed files with 25 additions and 15 deletions

View file

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import copy
from aldryn_apphooks_config.utils import get_app_instance
from django.utils.translation import activate

View file

@ -137,7 +137,6 @@ class AdminTest(BaseTest):
msg_mid.process_request(request)
post_admin = admin.site._registry[Post]
response = post_admin.edit_field(request, post.pk, 'en')
#print(response.content.decode('utf-8'))
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'])
@ -171,7 +170,11 @@ class ModelsTest(BaseTest):
'month': '%02d' % post.date_published.month,
'day': '%02d' % post.date_published.day,
'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())
with override('it'):
@ -180,7 +183,11 @@ class ModelsTest(BaseTest):
'month': '%02d' % post.date_published.month,
'day': '%02d' % post.date_published.day,
'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.assertNotEqual(url_it, url_en)

View file

@ -255,22 +255,27 @@ class ViewTest(BaseTest):
self.assertEqual(context['post_list'][0].title, 'Second post')
def test_feed(self):
pages = self.get_pages()
posts = self.get_posts()
pages = self.get_pages()
posts[0].tags.add('tag 1', 'tag 2', 'tag 3', 'tag 4')
posts[0].save()
posts[1].tags.add('tag 6', 'tag 2', 'tag 5', 'tag 8')
posts[1].save()
posts[0].set_current_language('en')
feed = LatestEntriesFeed()
feed.namespace = self.app_config_1.namespace
feed.config = self.app_config_1
self.assertEqual(list(feed.items()), [posts[0]])
request = self.get_page_request(pages[1], self.user, lang='en', edit=False)
xml = feed(request)
self.assertContains(xml, posts[0].get_absolute_url())
self.assertContains(xml, 'Blog articles on example.com')
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.namespace = self.app_config_1.namespace
feed.config = self.app_config_1
self.assertEqual(list(feed.items()), [posts[0]])
self.reload_urlconf()
xml = feed(request)
self.assertContains(xml, posts[0].get_absolute_url())
self.assertContains(xml, 'Blog articles on example.com')
with smart_override('it'):
with switch_language(posts[0], 'it'):
@ -278,7 +283,7 @@ class ViewTest(BaseTest):
feed.namespace = self.app_config_1.namespace
feed.config = self.app_config_1
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)
self.assertContains(xml, posts[0].get_absolute_url())
self.assertContains(xml, 'Articoli del blog su example.com')

View file

@ -7,7 +7,6 @@ deps =
django16: Django>=1.6,<1.7
django17: Django>=1.7,<1.8
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
cms31: https://github.com/divio/django-cms/archive/support/3.1.x.zip
cms32: https://github.com/divio/django-cms/archive/develop.zip