diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/tests.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 63bf73eb7..1b8601dfb 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -17,10 +17,13 @@ # See the file COPYING for details. +from BeautifulSoup import BeautifulSoup as Soup + from django.conf import settings from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.core.cache import cache +from django.core.exceptions import ValidationError from django.core.urlresolvers import reverse from django.template.defaultfilters import slugify from django.test import TestCase @@ -72,7 +75,7 @@ def create_user(): class WizardTest(object): - url = None + url_name = None wizard_name = '' steps = None condition_dict = None @@ -114,7 +117,21 @@ class WizardTest(object): next_idx = next_idx + 1 if next_form: - response = self.client.post(url, data) + try: + response = self.client.post(url, data) + except ValidationError as e: + 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.assertRedirects( response, '/{}/{}'.format(self.url_name, next_form)) |