summaryrefslogtreecommitdiff
path: root/archaeological_operations
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-11-09 13:40:06 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:23:19 +0100
commite9f71aa7435ad265e4a7d53978f8ce24033477d5 (patch)
treef5bda3993a31d8a749a37984c427b321897360c3 /archaeological_operations
parentf263918be794c60f3209e697b736335e4c5935c2 (diff)
downloadIshtar-e9f71aa7435ad265e4a7d53978f8ce24033477d5.tar.bz2
Ishtar-e9f71aa7435ad265e4a7d53978f8ce24033477d5.zip
Fix tests
Diffstat (limited to 'archaeological_operations')
-rw-r--r--archaeological_operations/tests.py155
1 files changed, 19 insertions, 136 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 5980a931a..a706e6aad 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -3508,9 +3508,8 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
"code_patriarche": "codeope1",
"operation_type": None,
"year": 2016,
+ "town": [],
},
- "townsgeneral": [],
- "parcelsgeneral": [],
},
ignored=(
"towns-operation_creation",
@@ -3527,9 +3526,8 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
"code_patriarche": "codeope2",
"operation_type": None,
"year": 2016,
+ "town": [],
},
- "townsgeneral": [],
- "parcelsgeneral": [],
},
ignored=(
"towns-operation_creation",
@@ -3546,9 +3544,8 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
"code_patriarche": "codeope3",
"operation_type": None,
"year": 2016,
+ "town": [],
},
- "towns": [],
- "parcels": [],
},
ignored=(
"townsgeneral-operation_creation",
@@ -3565,35 +3562,16 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
)
profile.files = True
profile.save()
-
- if "townsgeneral" not in self.form_datas[0].form_datas:
- return super(OperationWizardCreationTest, self).pre_wizard()
+
+ if "general" not in self.form_datas[0].form_datas:
+ super(OperationWizardCreationTest, self).pre_wizard()
+ return
town = self.create_towns()[0]
- town_data = {"town": town.pk}
- parcel_data = {
- "town": town.pk,
- "year": 2017,
- "section": "S",
- "parcel_number": "42",
- }
+ town_data = [town.pk]
for idx in range(2):
- self.form_datas[idx].append("townsgeneral", town_data)
- self.form_datas[idx].append("parcelsgeneral", parcel_data)
-
- FI = FileInit()
- FI.create_file()
- file = FI.item
- file.towns.add(town)
- parcel = models.Parcel.objects.create(
- town=town, year=2017, section="G", parcel_number="43"
- )
- 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})
+ self.form_datas[idx].form_datas["general"]["town"] = town_data
# diagnostic
ope_type = models.OperationType.objects.get(txt_idx="arch_diagnostic")
@@ -3607,17 +3585,6 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
def post_wizard(self):
self.assertEqual(models.Operation.objects.count(), self.operation_number + 3)
- operations = models.Operation.objects.order_by("-pk").all()[:3]
-
- parcel_ids = []
- for operation in operations:
- for parcel in operation.parcels.all():
- parcel_ids.append(parcel.external_id)
- self.assertEqual(
- list(sorted(parcel_ids)),
- ["codeope1-12345-S42", "codeope2-12345-S42", "codeope3-12345-G43"],
- )
- self.assertEqual(models.Parcel.objects.count(), self.parcel_number + 3)
class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
@@ -3644,9 +3611,7 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
"Update an operation",
form_datas={
"selec": {},
- "general": {"operation_type": 2, "year": 2017},
- "townsgeneral": [],
- "parcelsgeneral": [],
+ "general": {"operation_type": 2, "year": 2017, "town": []},
},
ignored=base_ignored_steps,
),
@@ -3658,9 +3623,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
"code_patriarche": "codeope42",
"operation_type": 2,
"year": 2017,
+ "town": [],
},
- "townsgeneral": [],
- "parcelsgeneral": [],
},
ignored=base_ignored_steps,
),
@@ -3668,9 +3632,7 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
"Operation: remove a parcel with no attached context record",
form_datas={
"selec": {},
- "general": {"operation_type": 2, "year": 2017},
- "townsgeneral": [],
- "parcelsgeneral": [],
+ "general": {"operation_type": 2, "year": 2017, "town": []},
},
ignored=base_ignored_steps,
),
@@ -3678,9 +3640,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
"Set an operation to an exiting operation code for this year",
form_datas={
"selec": {},
- "general": {"operation_type": 2, "operation_code": 42, "year": 2017},
- "townsgeneral": [],
- "parcelsgeneral": [],
+ "general": {"operation_type": 2, "operation_code": 42,
+ "year": 2017, "town": []},
},
ignored=base_ignored_steps,
error_expected="general",
@@ -3689,9 +3650,7 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
"Operation: change a parcel",
form_datas={
"selec": {},
- "general": {"operation_type": 2, "year": 2017},
- "townsgeneral": [],
- "parcelsgeneral": [],
+ "general": {"operation_type": 2, "year": 2017, "town": []},
},
ignored=base_ignored_steps,
),
@@ -3699,9 +3658,7 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
"Operation: change a town",
form_datas={
"selec": {},
- "general": {"operation_type": 2, "year": 2017},
- "townsgeneral": [],
- "parcelsgeneral": [],
+ "general": {"operation_type": 2, "year": 2017, "town": []},
},
ignored=base_ignored_steps,
),
@@ -3762,37 +3719,15 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
town_2 = self.create_towns(
datas={"numero_insee": "85000", "name": "South Peaks"}
)[-1]
- towns = [{"town": town.pk}, {"town": init_town.pk}]
- parcel_data = {
- "town": town.pk,
- "year": 2017,
- "section": "S",
- "parcel_number": "42",
- }
+ towns = [town.pk, init_town.pk]
for idx in range(0, 5):
for t in towns:
- self.form_datas[idx].append("townsgeneral", t)
- if idx != 4:
- self.form_datas[idx].append("parcelsgeneral", parcel_data)
-
- parcel_data_2 = {
- "town": init_parcel.town.pk,
- "year": init_parcel.year or "",
- "section": init_parcel.section,
- "pk": init_parcel.pk,
- "parcel_number": init_parcel.parcel_number,
- }
- data["parcelsgeneral"].append(parcel_data_2)
+ self.form_datas[idx].form_datas["general"]["town"].append(t)
- p = parcel_data.copy()
- p["parcel_number"] = "43"
- self.form_datas[4].form_datas["parcelsgeneral"] = [p]
-
- self.form_datas[5].form_datas["townsgeneral"] = [{"town": town_2.pk}]
+ self.form_datas[5].form_datas["general"]["town"] = [town_2.pk]
self.operation_number = models.Operation.objects.count()
- self.parcel_number = models.Parcel.objects.count()
def post_first_wizard(test_object, final_step_response):
test_object.assertEqual(
@@ -3801,17 +3736,6 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
operation = models.Operation.objects.get(pk=test_object.operations[0].pk)
test_object.assertEqual(operation.operation_type.pk, self.ope_type.pk)
test_object.assertEqual(operation.year, 2017)
- test_object.assertEqual(
- models.Parcel.objects.count(), test_object.parcel_number + 1
- )
- test_object.assertEqual(
- operation.parcels.count(), test_object.parcel_number + 1
- )
-
- def pre_second_wizard(test_object):
- test_object.form_datas[1].form_datas[
- "parcelsgeneral-operation_modification"
- ][0]["pk"] = models.Parcel.objects.get(parcel_number="42").pk
def post_second_wizard(test_object, final_step_response):
test_object.assertEqual(
@@ -3820,15 +3744,6 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
operation = models.Operation.objects.get(pk=test_object.operations[0].pk)
test_object.assertEqual(operation.operation_type.pk, self.ope_type.pk)
test_object.assertEqual(operation.year, 2017)
- test_object.assertEqual(
- models.Parcel.objects.count(), test_object.parcel_number + 1
- )
-
- # the init parcel is not submited but have a context record
- # the init parcel is not detached from the operation
- test_object.assertEqual(
- operation.parcels.count(), test_object.parcel_number + 1
- )
# update the external id on update
ContextRecord = apps.get_model(
"archaeological_context_records", "ContextRecord"
@@ -3836,11 +3751,6 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
cr = ContextRecord.objects.get(pk=self.cr.pk)
test_object.assertEqual(cr.external_id, "codeope42-12345-A1-Context record")
- def pre_third_wizard(test_object):
- parcel_nb = models.Parcel.objects.count()
- test_object.cr.delete()
- test_object.assertEqual(parcel_nb, models.Parcel.objects.count())
-
def post_third_wizard(test_object, final_step_response):
test_object.assertEqual(
models.Operation.objects.count(), test_object.operation_number
@@ -3848,38 +3758,14 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
operation = models.Operation.objects.get(pk=test_object.operations[0].pk)
test_object.assertEqual(operation.operation_type.pk, self.ope_type.pk)
test_object.assertEqual(operation.year, 2017)
- # with no attach the parcel is deleted
- test_object.assertEqual(
- operation.parcels.count(), test_object.parcel_number
- )
- # the parcel object is no more automatically deleted
- test_object.assertEqual(
- models.Parcel.objects.count(), test_object.parcel_number + 1
- )
-
- def pre_fifth_wizard(test_object):
- test_object.parcel_number = models.Parcel.objects.count()
- operation = models.Operation.objects.get(pk=test_object.operations[0].pk)
- test_object.operation_parcel_number = operation.parcels.count()
- test_object.form_datas[4].form_datas[
- "parcelsgeneral-operation_modification"
- ][0]["pk"] = models.Parcel.objects.get(parcel_number="42").pk
def post_fifth_wizard(test_object, final_step_response):
test_object.assertEqual(
models.Operation.objects.count(), test_object.operation_number
)
- operation = models.Operation.objects.get(pk=test_object.operations[0].pk)
- test_object.assertEqual(
- models.Parcel.objects.count(), test_object.parcel_number
- )
- test_object.assertEqual(
- operation.parcels.count(), test_object.operation_parcel_number
- )
def pre_sixth_wizard(test_object):
operation = models.Operation.objects.get(pk=test_object.operations[0].pk)
- operation.parcels.clear()
operation.towns.clear()
def post_sixth_wizard(test_object, final_step_response):
@@ -3890,11 +3776,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase):
)
self.form_datas[0].extra_tests = [post_first_wizard]
- self.form_datas[1].pre_tests = [pre_second_wizard]
self.form_datas[1].extra_tests = [post_second_wizard]
- self.form_datas[2].pre_tests = [pre_third_wizard]
self.form_datas[2].extra_tests = [post_third_wizard]
- self.form_datas[4].pre_tests = [pre_fifth_wizard]
self.form_datas[4].extra_tests = [post_fifth_wizard]
self.form_datas[5].pre_tests = [pre_sixth_wizard]
self.form_datas[5].extra_tests = [post_sixth_wizard]