Update tests
This commit is contained in:
parent
3a03cb71fe
commit
96bfefadea
5 changed files with 17 additions and 7 deletions
|
@ -7,16 +7,19 @@ import os
|
|||
from cms.utils.i18n import get_language_list
|
||||
from cmsplugin_filer_image.models import ThumbnailOption
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.files import File as DjangoFile
|
||||
from django.http import SimpleCookie
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.utils.translation import activate
|
||||
from filer.models import File, Image
|
||||
from PIL import Image as PilImage, ImageChops, ImageDraw
|
||||
from PIL import Image as PilImage, ImageDraw
|
||||
from six import StringIO
|
||||
|
||||
from djangocms_blog.models import BlogCategory, Post
|
||||
from djangocms_helper.utils import create_user
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class BaseTest(TestCase):
|
||||
|
@ -52,9 +55,9 @@ class BaseTest(TestCase):
|
|||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.request_factory = RequestFactory()
|
||||
cls.user = User.objects.create(username='admin', is_staff=True, is_superuser=True)
|
||||
cls.user_staff = User.objects.create(username='staff', is_staff=True)
|
||||
cls.user_normal = User.objects.create(username='normal')
|
||||
cls.user = create_user('admin', 'admin@admin.com', 'admin', is_staff=True, is_superuser=True)
|
||||
cls.user_staff = create_user('staff', 'staff@admin.com', 'staff', is_staff=True)
|
||||
cls.user_normal = create_user('normal', 'normal@admin.com', 'normal')
|
||||
|
||||
def setUp(self):
|
||||
activate('en')
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from cms.api import add_plugin
|
||||
from cms.utils.copy_plugins import copy_plugins_to
|
||||
from cms.utils.plugins import downcast_plugins
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.timezone import now
|
||||
import parler
|
||||
|
@ -115,8 +116,12 @@ class ModelsTest(BaseTest):
|
|||
|
||||
# No fallback
|
||||
parler.appsettings.PARLER_LANGUAGES['default']['hide_untranslated'] = True
|
||||
for index, lang in enumerate(parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk]):
|
||||
parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk][index]['hide_untranslated'] = True
|
||||
self.assertEqual(len(Post.objects.filter_by_language('it')), 1)
|
||||
parler.appsettings.PARLER_LANGUAGES['default']['hide_untranslated'] = False
|
||||
for index, lang in enumerate(parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk]):
|
||||
parler.appsettings.PARLER_LANGUAGES[Site.objects.get_current().pk][index]['hide_untranslated'] = False
|
||||
|
||||
def test_tag_cloud(self):
|
||||
post1 = self._get_post(self.data['en'][0])
|
||||
|
|
|
@ -45,7 +45,7 @@ class PluginTest(BaseTest):
|
|||
request = self.get_page_request(page1, self.user, r'/en/blog/', lang_code='en', edit=True)
|
||||
context = RequestContext(request, {})
|
||||
rendered = plugin.render_plugin(context, ph)
|
||||
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-author', kwargs={'username': self.user.username})) > -1)
|
||||
self.assertTrue(rendered.find(reverse('djangocms_blog:posts-author', kwargs={'username': self.user.get_username()})) > -1)
|
||||
self.assertTrue(rendered.find('2 articles') > -1)
|
||||
|
||||
def test_plugin_tags(self):
|
||||
|
|
|
@ -16,6 +16,7 @@ urlpatterns = patterns('',
|
|||
url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
|
||||
{'document_root': get_cms_setting('MEDIA_ROOT'), 'show_indexes': True}),
|
||||
url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
|
||||
url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')),
|
||||
)
|
||||
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
|
|
|
@ -3,6 +3,7 @@ from django.contrib.auth.models import AnonymousUser
|
|||
from django.http import Http404
|
||||
from django.utils.translation import activate
|
||||
from django.utils.timezone import now
|
||||
from djangocms_blog.models import Post
|
||||
from djangocms_blog.feeds import LatestEntriesFeed, TagFeed
|
||||
from djangocms_blog.sitemaps import BlogSitemap
|
||||
from djangocms_blog.views import (PostListView, PostDetailView,
|
||||
|
@ -132,7 +133,7 @@ class ViewTest(BaseTest):
|
|||
activate('en')
|
||||
view_obj = AuthorEntriesView()
|
||||
view_obj.request = request
|
||||
view_obj.kwargs = {'username': 'admin'}
|
||||
view_obj.kwargs = {'username': self.user.get_username()}
|
||||
qs = view_obj.get_queryset()
|
||||
self.assertEqual(qs.count(), 2)
|
||||
self.assertEqual(set(qs), set([post1, post2]))
|
||||
|
|
Loading…
Reference in a new issue