diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/tests.py | 27 |
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() |