This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# -*- coding: utf-8 -*- | ||
import sys | ||
|
||
from distutils.version import LooseVersion | ||
|
||
import cms | ||
|
||
from djangocms_helper.utils import create_user | ||
|
||
from aldryn_faq.cms_wizards import CreateFaqQuestionForm | ||
|
||
from .test_base import AldrynFaqTest | ||
|
||
|
||
if sys.version_info < (2, 7): | ||
import unittest2 as unittest | ||
else: | ||
import unittest | ||
|
||
# The CMS wizard system was introduced in 3.2.0 | ||
CMS_3_2 = LooseVersion(cms.__version__) >= LooseVersion('3.2.0') | ||
|
||
|
||
@unittest.skipUnless(CMS_3_2, "No wizard support in CMS < 3.2") | ||
class TestFAQWizard(AldrynFaqTest): | ||
|
||
def setUp(self): | ||
super(TestFAQWizard, self).setUp() | ||
username = 'admin_user' | ||
password = 'test' | ||
self.admin_user = create_user( | ||
username=username, | ||
email='test@example.com', | ||
password=password, | ||
is_superuser=True, | ||
) | ||
self.client.login(username=username, password=password) | ||
|
||
def test_question_wizard(self): | ||
data = { | ||
'title': 'Where are we?', | ||
'answer': 'Here.', | ||
'answer_text': '<p>Interesting question..</p>', | ||
'category': self.category1.pk, | ||
} | ||
form = CreateFaqQuestionForm( | ||
data=data, | ||
wizard_language='en', | ||
wizard_user=self.admin_user, | ||
) | ||
self.assertTrue(form.is_valid()) | ||
question = form.save() | ||
|
||
url = question.get_absolute_url('en') | ||
response = self.client.get(url) | ||
self.assertContains(response, 'Where are we?', status_code=200) | ||
self.assertContains(response, 'Here.', status_code=200) |