summaryrefslogtreecommitdiff
path: root/ishtar_common/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-11-30 13:20:53 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-11-30 13:20:53 +0100
commit8b666443667f92e014d70a4247c7885375bba610 (patch)
tree7e216f7c036ae568407d46359dea361f2a641098 /ishtar_common/tests.py
parent62cac0ec03a96d5f358148cf6dff2a21ccf20854 (diff)
downloadIshtar-8b666443667f92e014d70a4247c7885375bba610.tar.bz2
Ishtar-8b666443667f92e014d70a4247c7885375bba610.zip
Simple treatment form. Treatment listing. (refs #3365)
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r--ishtar_common/tests.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 0c4bbda08..dbe3df4a5 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -75,6 +75,32 @@ def create_user():
return username, password, user
+class WizardTestFormData(object):
+ """
+ Test set to simulate wizard steps
+ """
+ def __init__(self, name, form_datas, ignored=[], extra_tests=[]):
+ """
+ :param name: explicit name of the test
+ :param form_datas: dict with data for each step - dict key are wizard
+ step name
+ :param ignored: steps to be ignored in wizard processing
+ :param extra_tests: list of extra tests. Theses tests must be functions
+ accepting two parameters: the current test object and the final step
+ response
+ """
+ self.form_datas = form_datas
+ self.ignored = ignored[:]
+ self.extra_tests = extra_tests
+
+ def tests(self, test_object, final_step_response):
+ """
+ Specific tests for theses datas. Raise Exception if not OK.
+ """
+ for test in self.extra_tests:
+ test(test_object, final_step_response)
+
+
class WizardTest(object):
url_name = None
wizard_name = ''
@@ -95,7 +121,9 @@ class WizardTest(object):
def test_wizard(self):
url = reverse(self.url_name)
self.pre_wizard()
- for form_data, ignored in self.form_datas:
+ for test_form_data in self.form_datas:
+ form_data = test_form_data.form_datas
+ ignored = test_form_data.ignored
for idx, step in enumerate(self.steps):
current_step, current_form = step
if current_step in ignored:
@@ -138,6 +166,7 @@ class WizardTest(object):
'/{}/{}'.format(self.url_name, next_form))
else:
response = self.client.post(url, data, follow=True)
+ test_form_data.tests(self, response)
self.post_wizard()