diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-03-09 11:22:37 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:27 +0200 |
commit | 57b2ff618a0011f54b69b08654282987d5b47c6b (patch) | |
tree | 5ef8e8b66009dfcfd6ad9c219fec9fb66230adec /ishtar_common/tests.py | |
parent | bf6076664862f7b66062a6ab73271440ad85939a (diff) | |
download | Ishtar-57b2ff618a0011f54b69b08654282987d5b47c6b.tar.bz2 Ishtar-57b2ff618a0011f54b69b08654282987d5b47c6b.zip |
Wizards: fix going to previous step
Diffstat (limited to 'ishtar_common/tests.py')
-rw-r--r-- | ishtar_common/tests.py | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index f6cd3eff4..111626416 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -393,6 +393,39 @@ class WizardTest(object): raise ValidationError(msg) return response + def wizard_post_test(self, idx, data_idx, url, current_step, form_data, + test_form_data, ignored): + next_form_is_checked = len(self.steps) > idx + 1 and \ + self.steps[idx + 1][0] not in ignored + data = [] + if current_step in form_data: + data = form_data[current_step] + response = self.wizard_post( + self.client, url, current_step, data, + not next_form_is_checked) + + if current_step == test_form_data.error_expected: + with self.assertRaises(ValidationError): + self.check_response(response, current_step, data_idx) + else: + self.check_response(response, current_step, data_idx) + + if next_form_is_checked: + next_form = self.steps[idx + 1][0] + self.assertRedirects( + response, + '/{}/{}'.format(self.url_name, next_form), + msg_prefix="Dataset n{} Redirection to {} has failed - " + "Error on previous form ({})?".format( + data_idx + 1, next_form, current_step) + ) + if idx == len(self.steps) - 1: + # last form + self.assertRedirects( + response, + '/{}/done'.format(self.url_name)) + return response + def test_wizard(self): if self.pass_test(): return @@ -402,7 +435,7 @@ class WizardTest(object): test_form_data.inits(self) form_data = test_form_data.form_datas ignored = test_form_data.ignored - previous_step, back_tested = None, False + previous_step, back_tested, response = None, False, None for idx, step in enumerate(self.steps): current_step, current_form = step if current_step in ignored: @@ -413,40 +446,13 @@ class WizardTest(object): # test going back on a form response = self.wizard_post( self.client, url, current_step, None, - extra_data={"form_previous_step": previous_step} + extra_data={"form_prev_step": previous_step} ) self.assertEqual(response.status_code, 200) back_tested = True - - next_form_is_checked = len(self.steps) > idx + 1 and \ - self.steps[idx + 1][0] not in ignored - data = [] - if current_step in form_data: - data = form_data[current_step] - response = self.wizard_post( - self.client, url, current_step, data, - not next_form_is_checked) - - if current_step == test_form_data.error_expected: - with self.assertRaises(ValidationError): - self.check_response(response, current_step, data_idx) - else: - self.check_response(response, current_step, data_idx) - - if next_form_is_checked: - next_form = self.steps[idx + 1][0] - self.assertRedirects( - response, - '/{}/{}'.format(self.url_name, next_form), - msg_prefix="Dataset n{} Redirection to {} has failed -" - " Error on previous form ({})?".format( - data_idx + 1, next_form, current_step) - ) - if idx == len(self.steps) - 1: - # last form - self.assertRedirects( - response, - '/{}/done'.format(self.url_name)) + response = self.wizard_post_test( + idx, data_idx, url, current_step, form_data, test_form_data, + ignored) test_form_data.tests(self, response) self.post_wizard() |