summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-01-23 11:19:49 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2020-07-01 18:01:59 +0200
commit3092612f54ecaba7ede5e5564f40ac36e873dd67 (patch)
treea0eb208693797006754d81f5f2f7167cab5d0e1c
parentba421b42b5411331d77e41706fef543130b427bd (diff)
downloadIshtar-3092612f54ecaba7ede5e5564f40ac36e873dd67.tar.bz2
Ishtar-3092612f54ecaba7ede5e5564f40ac36e873dd67.zip
Fix test initialization for wizards
-rw-r--r--archaeological_operations/tests.py28
-rw-r--r--ishtar_common/tests.py10
2 files changed, 16 insertions, 22 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index af6988568..9cb715a6f 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -2622,19 +2622,16 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
if 'townsgeneral' not in \
self.form_datas[0].form_datas:
return super(OperationWizardCreationTest, self).pre_wizard()
+
town = self.create_towns()[0]
town_data = {'town': town.pk}
- self.form_datas[0].form_datas[
- 'townsgeneral'].append(town_data)
- self.form_datas[1].form_datas[
- 'townsgeneral'].append(town_data)
parcel_data = {
'town': town.pk, 'year': 2017, 'section': 'S',
'parcel_number': '42'}
- self.form_datas[0].form_datas[
- 'parcelsgeneral'].append(parcel_data)
- self.form_datas[1].form_datas[
- 'parcelsgeneral'].append(parcel_data)
+
+ for idx in range(0, 2):
+ self.form_datas[idx].append('townsgeneral', town_data)
+ self.form_datas[idx].append('parcelsgeneral', parcel_data)
FI = FileInit()
FI.create_file()
@@ -2645,6 +2642,7 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
)
file.parcels.add(parcel)
self.form_datas[2].set('filechoice', 'associated_file', file.pk)
+ self.form_datas[2].append('parcelsgeneral', {'parcel': parcel.pk})
self.form_datas[2].append('towns', town_data)
self.form_datas[2].append('parcels', {'parcel': parcel.pk})
@@ -2787,18 +2785,14 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
town = self.create_towns(
datas={'numero_insee': '67890', 'name': 'Twin Peaks'})[-1]
towns = [{'town': town.pk}, {'town': init_town.pk}]
- data['townsgeneral'] = towns
- data2['townsgeneral'] = towns
- data3['townsgeneral'] = towns
- data4['townsgeneral'] = towns
-
parcel_data = {
'town': town.pk, 'year': 2017, 'section': 'S',
'parcel_number': '42'}
- data['parcelsgeneral'].append(parcel_data)
- data2['parcelsgeneral'].append(parcel_data)
- data3['parcelsgeneral'].append(parcel_data)
- data4['parcelsgeneral'].append(parcel_data)
+
+ for idx in range(0, 4):
+ for t in towns:
+ self.form_datas[idx].append('townsgeneral', t)
+ self.form_datas[idx].append('parcelsgeneral', parcel_data)
parcel_data_2 = {
'town': init_parcel.town.pk, 'year': init_parcel.year or '',
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 0eda481b1..bfb66fee0 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -357,7 +357,7 @@ class WizardTestFormData(object):
:return: None
"""
if form_name not in self.form_datas:
- self.form_datas[form_name] = {}
+ self.form_datas[form_name] = []
self.form_datas[form_name].append(value)
def inits(self, test_object):
@@ -367,7 +367,7 @@ class WizardTestFormData(object):
suffix = '-' + test_object.url_name
# if form names are defined without url_name fix it
- for form_name in self.form_datas.keys():
+ for form_name in list(self.form_datas.keys()):
if suffix in form_name:
continue
self.form_datas[form_name + suffix] = self.form_datas.pop(form_name)
@@ -440,9 +440,9 @@ class WizardTest(object):
errors = []
for li in errorlist:
lbl = li.findParent().findParent().findChild().text
- errors.append(u"{} - {}".format(lbl, li.text))
- raise ValidationError(u"Errors: {} on {} - dataset {}.".format(
- u" ".join(errors), current_step, data_idx + 1))
+ errors.append("{} - {}".format(lbl, li.text))
+ raise ValidationError("Errors: {} on {} - dataset {}.".format(
+ " ".join(errors), current_step, data_idx + 1))
@classmethod
def wizard_post(cls, client, url, current_step, form_data=None,