Fix test
This commit is contained in:
parent
3e732c0e39
commit
e43b15c0b7
1 changed files with 20 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
# -*- 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 sys
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
import cms
|
import cms
|
||||||
|
@ -15,6 +16,21 @@ except ImportError:
|
||||||
|
|
||||||
class WizardTest(BaseTest):
|
class WizardTest(BaseTest):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
try:
|
||||||
|
from cms.wizards.wizard_pool import wizard_pool
|
||||||
|
delete = [
|
||||||
|
'djangocms_blog',
|
||||||
|
'djangocms_blog.cms_wizards',
|
||||||
|
]
|
||||||
|
for module in delete:
|
||||||
|
if module in sys.modules:
|
||||||
|
del sys.modules[module]
|
||||||
|
wizard_pool._reset()
|
||||||
|
except ImportError:
|
||||||
|
# Not in django CMS 3.2+, no cleanup needed
|
||||||
|
pass
|
||||||
|
|
||||||
@skipIf(LooseVersion(cms.__version__) < LooseVersion('3.2'),
|
@skipIf(LooseVersion(cms.__version__) < LooseVersion('3.2'),
|
||||||
reason='Wizards not available for django CMS < 3.2')
|
reason='Wizards not available for django CMS < 3.2')
|
||||||
def test_wizard(self):
|
def test_wizard(self):
|
||||||
|
@ -23,7 +39,6 @@ class WizardTest(BaseTest):
|
||||||
"""
|
"""
|
||||||
from cms.wizards.wizard_pool import wizard_pool
|
from cms.wizards.wizard_pool import wizard_pool
|
||||||
self.get_pages()
|
self.get_pages()
|
||||||
wizard_pool._discover()
|
|
||||||
|
|
||||||
titles = [entry.title for entry in wizard_pool.get_entries()]
|
titles = [entry.title for entry in wizard_pool.get_entries()]
|
||||||
self.assertTrue('New Blog' in titles)
|
self.assertTrue('New Blog' in titles)
|
||||||
|
@ -35,12 +50,11 @@ class WizardTest(BaseTest):
|
||||||
from cms.wizards.wizard_pool import wizard_pool
|
from cms.wizards.wizard_pool import wizard_pool
|
||||||
from djangocms_blog.models import Post
|
from djangocms_blog.models import Post
|
||||||
self.get_pages()
|
self.get_pages()
|
||||||
wizard_pool._discover()
|
|
||||||
|
|
||||||
wizs = [entry for entry in wizard_pool.get_entries() if entry.model == Post]
|
wizs = [entry for entry in wizard_pool.get_entries() if entry.model == Post]
|
||||||
for index, wiz in enumerate(wizs):
|
for wiz in wizs:
|
||||||
app_config = self.app_config_1.pk if index == 0 else self.app_config_2.pk
|
app_config = self.app_config_1.pk if wiz.title == 'New Blog' else self.app_config_2.pk
|
||||||
form = wiz.form(initial={'app_config': app_config})
|
form = wiz.form()
|
||||||
self.assertTrue(form.fields['app_config'].widget.attrs['disabled'])
|
self.assertTrue(form.fields['app_config'].widget.attrs['disabled'])
|
||||||
|
|
||||||
form = wiz.form(data={
|
form = wiz.form(data={
|
||||||
|
@ -50,6 +64,7 @@ class WizardTest(BaseTest):
|
||||||
}, prefix=1)
|
}, prefix=1)
|
||||||
self.assertEqual(form.default_appconfig, app_config)
|
self.assertEqual(form.default_appconfig, app_config)
|
||||||
self.assertTrue(form.is_valid())
|
self.assertTrue(form.is_valid())
|
||||||
|
self.assertTrue(form.cleaned_data['app_config'], app_config)
|
||||||
|
|
||||||
def test_wizard_import(self):
|
def test_wizard_import(self):
|
||||||
# The following import should to fail in any django CMS version
|
# The following import should to fail in any django CMS version
|
||||||
|
|
Loading…
Add table
Reference in a new issue