diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-07-16 14:56:15 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-07-16 14:56:15 +0200 |
commit | d3577c944b73dd80a30c74f0da33d65f33c72cd9 (patch) | |
tree | 3c98b4bb6a73da34269ca9bcd686d7300992041d /ishtar_common/tests.py | |
parent | 6cc8e35724ec16bdb8366b52d002020120037c68 (diff) | |
download | Ishtar-d3577c944b73dd80a30c74f0da33d65f33c72cd9.tar.bz2 Ishtar-d3577c944b73dd80a30c74f0da33d65f33c72cd9.zip |
Test administrativ act creation - improve test wizard
Diffstat (limited to 'ishtar_common/tests.py')
-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)) |