This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
test_wizards.py
57 lines (44 loc) · 1.55 KB
/
test_wizards.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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)