Add tests for django-knocker support
This commit is contained in:
parent
bbaa8aca6f
commit
e3f89d0ea2
4 changed files with 64 additions and 3 deletions
|
@ -13,7 +13,6 @@ HELPER_SETTINGS = dict(
|
|||
'filer',
|
||||
'parler',
|
||||
'meta',
|
||||
'meta_mixin',
|
||||
'easy_thumbnails',
|
||||
'django.contrib.sitemaps',
|
||||
'djangocms_text_ckeditor',
|
||||
|
@ -110,6 +109,25 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
import meta_mixin # pragma: no cover # NOQA
|
||||
HELPER_SETTINGS['INSTALLED_APPS'].append('meta_mixin')
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
import knocker # pragma: no cover # NOQA
|
||||
HELPER_SETTINGS['INSTALLED_APPS'].append('knocker')
|
||||
HELPER_SETTINGS['CHANNEL_LAYERS'] = {
|
||||
'default': {
|
||||
'BACKEND': 'asgiref.inmemory.ChannelLayer',
|
||||
'ROUTING': 'knocker.routing.channel_routing',
|
||||
},
|
||||
}
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def run():
|
||||
from djangocms_helper import runner
|
||||
|
|
|
@ -19,6 +19,7 @@ from django.utils.html import strip_tags
|
|||
from django.utils.timezone import now
|
||||
from django.utils.translation import get_language, override
|
||||
from djangocms_helper.utils import CMS_30
|
||||
from parler.utils.context import smart_override
|
||||
from taggit.models import Tag
|
||||
|
||||
from djangocms_blog.cms_appconfig import BlogConfig, BlogConfigForm
|
||||
|
@ -27,6 +28,11 @@ from djangocms_blog.settings import get_setting
|
|||
|
||||
from .base import BaseTest
|
||||
|
||||
try:
|
||||
from unittest import SkipTest
|
||||
except ImportError:
|
||||
from django.utils.unittest import SkipTest
|
||||
|
||||
|
||||
class AdminTest(BaseTest):
|
||||
|
||||
|
@ -615,3 +621,36 @@ class ModelsTest(BaseTest):
|
|||
|
||||
plugin = add_plugin(post1.content, 'BlogArchivePlugin', language='en', app_config=self.app_config_1)
|
||||
self.assertEqual(force_text(plugin.__str__()), 'generic blog plugin')
|
||||
|
||||
|
||||
class KnockerTest(BaseTest):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
try:
|
||||
import knocker
|
||||
super(KnockerTest, cls).setUpClass()
|
||||
except ImportError:
|
||||
raise SkipTest('django-knocker not installed, skipping tests')
|
||||
|
||||
def test_model_attributes(self):
|
||||
self.get_pages()
|
||||
posts = self.get_posts()
|
||||
|
||||
for language in posts[0].get_available_languages():
|
||||
with smart_override(language):
|
||||
posts[0].set_current_language(language)
|
||||
knock_create = posts[0].as_knock(True)
|
||||
self.assertEqual(knock_create['title'],
|
||||
'new {0}'.format(posts[0]._meta.verbose_name))
|
||||
self.assertEqual(knock_create['message'], posts[0].title)
|
||||
self.assertEqual(knock_create['language'], language)
|
||||
|
||||
for language in posts[0].get_available_languages():
|
||||
with smart_override(language):
|
||||
posts[0].set_current_language(language)
|
||||
knock_create = posts[0].as_knock(False)
|
||||
self.assertEqual(knock_create['title'],
|
||||
'new {0}'.format(posts[0]._meta.verbose_name))
|
||||
self.assertEqual(knock_create['message'], posts[0].title)
|
||||
self.assertEqual(knock_create['language'], language)
|
||||
|
|
|
@ -30,6 +30,7 @@ class WizardTest(BaseTest):
|
|||
except ImportError:
|
||||
# Not in django CMS 3.2+, no cleanup needed
|
||||
pass
|
||||
super(WizardTest, self).setUp()
|
||||
|
||||
@skipIf(LooseVersion(cms.__version__) < LooseVersion('3.2'),
|
||||
reason='Wizards not available for django CMS < 3.2')
|
||||
|
|
7
tox.ini
7
tox.ini
|
@ -1,5 +1,5 @@
|
|||
[tox]
|
||||
envlist = pep8,isort,py{35,34,27}-django{19}-cms{32},py{35,34,33,27}-django{18}-cms{32,31},py{34,33,27}-django{17,16}-cms{32,31,30},py{26}-django16-cms{31,30}
|
||||
envlist = pep8,isort,py{35,34,27}-django{19}-{cms32,knocker},py{35,34,33,27}-django{18}-cms{32,31},py{34,33,27}-django{17,16}-cms{32,31,30},py{26}-django16-cms{31,30}
|
||||
|
||||
[testenv]
|
||||
commands = {env:COMMAND:python} cms_helper.py test djangocms_blog --no-migrate
|
||||
|
@ -18,7 +18,10 @@ deps =
|
|||
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/release/3.2.x.zip
|
||||
https://github.com/nephila/django-meta-mixin/archive/master.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
|
||||
django-meta>=1.0b3
|
||||
https://github.com/nephila/djangocms-helper/archive/develop.zip
|
||||
py26: unittest2
|
||||
https://github.com/aldryn/aldryn-apphooks-config/archive/master.zip
|
||||
|
|
Loading…
Reference in a new issue