More tests
This commit is contained in:
parent
e589e4f531
commit
3e732c0e39
2 changed files with 30 additions and 2 deletions
|
@ -15,8 +15,9 @@ try:
|
|||
default_appconfig = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['initial']['app_config'] = self.default_appconfig
|
||||
if 'data' in kwargs:
|
||||
if kwargs.get('initial', False):
|
||||
kwargs['initial']['app_config'] = self.default_appconfig
|
||||
if kwargs.get('data', False):
|
||||
kwargs['data']['1-app_config'] = self.default_appconfig
|
||||
super(PostWizardForm, self).__init__(*args, **kwargs)
|
||||
self.fields['app_config'].widget.attrs['disabled'] = True
|
||||
|
@ -37,6 +38,7 @@ try:
|
|||
title=_('New {0}').format(config.object_name),
|
||||
weight=200,
|
||||
form=new_form,
|
||||
model=Post,
|
||||
description=_('Create a new {0} in {1}').format(config.object_name, config.app_title),
|
||||
)
|
||||
wizard_pool.register(post_wizard)
|
||||
|
|
|
@ -28,3 +28,29 @@ class WizardTest(BaseTest):
|
|||
titles = [entry.title for entry in wizard_pool.get_entries()]
|
||||
self.assertTrue('New Blog' in titles)
|
||||
self.assertTrue('New Article' in titles)
|
||||
|
||||
@skipIf(LooseVersion(cms.__version__) < LooseVersion('3.2'),
|
||||
reason='Wizards not available for django CMS < 3.2')
|
||||
def test_wizard_init(self):
|
||||
from cms.wizards.wizard_pool import wizard_pool
|
||||
from djangocms_blog.models import Post
|
||||
self.get_pages()
|
||||
wizard_pool._discover()
|
||||
|
||||
wizs = [entry for entry in wizard_pool.get_entries() if entry.model == Post]
|
||||
for index, wiz in enumerate(wizs):
|
||||
app_config = self.app_config_1.pk if index == 0 else self.app_config_2.pk
|
||||
form = wiz.form(initial={'app_config': app_config})
|
||||
self.assertTrue(form.fields['app_config'].widget.attrs['disabled'])
|
||||
|
||||
form = wiz.form(data={
|
||||
'1-title': 'title',
|
||||
'1-abstract': 'abstract',
|
||||
'1-categories': [self.category_1.pk],
|
||||
}, prefix=1)
|
||||
self.assertEqual(form.default_appconfig, app_config)
|
||||
self.assertTrue(form.is_valid())
|
||||
|
||||
def test_wizard_import(self):
|
||||
# The following import should to fail in any django CMS version
|
||||
from djangocms_blog import cms_wizards # NOQA
|
||||
|
|
Loading…
Reference in a new issue