summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-20 13:50:37 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-12-20 13:50:37 +0100
commit8b2ce8ee16a8ce40c09c5e5cb7bd9e8cd48a3368 (patch)
tree8b0e6033fe85891b6bb0eef6d4665b6465996dc2 /ishtar_common
parentf42ea0f49a4d5c5a6cb15758d2bc8edaacc49ec3 (diff)
downloadIshtar-8b2ce8ee16a8ce40c09c5e5cb7bd9e8cd48a3368.tar.bz2
Ishtar-8b2ce8ee16a8ce40c09c5e5cb7bd9e8cd48a3368.zip
Fix find creation (refs #3399) - improve wizard test management
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/tests.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index dbe3df4a5..095956090 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -118,6 +118,18 @@ class WizardTest(object):
def post_wizard(self):
pass
+ def check_response(self, response, current_step):
+ if "errorlist" in response.content:
+ soup = Soup(response.content)
+ errorlist = soup.findAll(
+ "ul", {"class": "errorlist"})
+ errors = []
+ for li in errorlist:
+ lbl = li.findParent().findParent().findChild().text
+ errors.append(u"{} - {}".format(lbl, li.text))
+ raise ValidationError(u"Errors: {} on {}.".format(
+ u" ".join(errors), current_step))
+
def test_wizard(self):
url = reverse(self.url_name)
self.pre_wizard()
@@ -144,28 +156,21 @@ class WizardTest(object):
next_form = self.steps[idx + 1][0]
break
next_idx = next_idx + 1
-
if next_form:
try:
response = self.client.post(url, data)
except ValidationError as e:
+ # on ManagementForm data is missing or has been tampered
+ # error verify the wizard_name or step name
raise ValidationError(u"Errors: {} on {}.".format(
u" - ".join(e.messages), current_step))
- if "errorlist" in response.content:
- soup = Soup(response.content)
- errorlist = soup.findAll(
- "ul", {"class": "errorlist"})
- errors = []
- for li in errorlist:
- lbl = li.findParent().findParent().findChild().text
- errors.append(u"{} - {}".format(lbl, li.text))
- raise ValidationError(u"Errors: {} on {}.".format(
- u" ".join(errors), current_step))
+ self.check_response(response, current_step)
self.assertRedirects(
response,
'/{}/{}'.format(self.url_name, next_form))
else:
response = self.client.post(url, data, follow=True)
+ self.check_response(response, current_step)
test_form_data.tests(self, response)
self.post_wizard()