diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-14 12:01:43 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-14 12:01:43 +0200 |
commit | 7a1e27fdafbf1a3bc864502f462d88270a18cd01 (patch) | |
tree | 5d192a0f58e68030f1c8e1d258f2b9947231df12 | |
parent | 4fe37389d2271ee003e1a42a63f081be9da1d369 (diff) | |
download | Ishtar-7a1e27fdafbf1a3bc864502f462d88270a18cd01.tar.bz2 Ishtar-7a1e27fdafbf1a3bc864502f462d88270a18cd01.zip |
Fix tests
-rw-r--r-- | archaeological_context_records/tests.py | 4 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 16 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 72 |
3 files changed, 58 insertions, 34 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index b26823777..e29c37511 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -50,6 +50,10 @@ CONTEXT_RECORD_FIXTURES = FILE_FIXTURES + [ CONTEXT_RECORD_TOWNS_FIXTURES = FILE_TOWNS_FIXTURES + [ settings.ROOT_PATH + '../archaeological_context_records/fixtures/initial_data-fr.json', + '../archaeological_context_records/fixtures/' + 'initial_data_relation_type_norel-fr.json', + '../archaeological_context_records/fixtures/' + 'initial_data_relation_type-fr.json', ] diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 3f34ab495..e6eafd3ed 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -206,15 +206,15 @@ class TreatmentWizardCreationTest(WizardTest, FindInit, TestCase): FormData( 'Move treament', form_datas={ - 'file-treatment_creation': {}, - 'basetreatment-treatment_creation': { - 'treatment_type': 4, # move + 'file': {}, + 'basetreatment': { + 'treatment_type': None, 'person': 1, # doer 'location': 1, # associated warehouse 'year': 2016, 'target_is_basket': False }, - 'selecfind-treatment_creation': { + 'selecfind': { 'pk': 1, 'resulting_pk': 1 } @@ -236,10 +236,14 @@ class TreatmentWizardCreationTest(WizardTest, FindInit, TestCase): person = Person.objects.create(name="default") person.id = 1 person.save() + + trt_type = models.TreatmentType.objects.get(txt_idx='moving') + self.form_datas[0].set('basetreatment', 'treatment_type', trt_type.pk) + self.find, base_find = self.get_default_find(force=True) - self.form_datas[0].form_datas['selecfind-treatment_creation'][ + self.form_datas[0].form_datas['selecfind'][ 'pk'] = self.find.pk - self.form_datas[0].form_datas['selecfind-treatment_creation'][ + self.form_datas[0].form_datas['selecfind'][ 'resulting_pk'] = self.find.pk self.treatment_number = models.Treatment.objects.count() super(TreatmentWizardCreationTest, self).pre_wizard() diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index c32c050fd..0c71448b3 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1152,7 +1152,7 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): form_datas={ 'filechoice': {}, 'general': { - 'operation_type': 1, # preventive diag + 'operation_type': None, 'year': 2016}, 'townsgeneral': [], 'parcelsgeneral': [], @@ -1166,7 +1166,7 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): form_datas={ 'filechoice': {}, 'general': { - 'operation_type': 1, # preventive diag + 'operation_type': None, 'year': 2016}, 'townsgeneral': [], 'parcelsgeneral': [], @@ -1180,7 +1180,7 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): form_datas={ 'filechoice': {}, 'general': { - 'operation_type': 1, # preventive diag + 'operation_type': None, 'year': 2016}, 'towns': [], 'parcels': [], @@ -1226,6 +1226,12 @@ class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): self.form_datas[2].append('towns', town_data) self.form_datas[2].append('parcels', {'parcel': parcel.pk}) + # diagnostic + ope_type = models.OperationType.objects.get(txt_idx='arch_diagnostic') + self.form_datas[0].set('general', 'operation_type', ope_type.pk) + self.form_datas[1].set('general', 'operation_type', ope_type.pk) + self.form_datas[2].set('general', 'operation_type', ope_type.pk) + self.operation_number = models.Operation.objects.count() self.parcel_number = models.Parcel.objects.count() super(OperationWizardCreationTest, self).pre_wizard() @@ -1256,36 +1262,36 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): FormData( "Update an operation", form_datas={ - 'selec-operation_modification': {}, - 'general-operation_modification': { + 'selec': {}, + 'general': { 'operation_type': 2, 'year': 2017}, - 'townsgeneral-operation_modification': [], - 'parcelsgeneral-operation_modification': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=base_ignored_steps ), FormData( "Operation: try to remove a parcel with attached context record", form_datas={ - 'selec-operation_modification': {}, - 'general-operation_modification': { + 'selec': {}, + 'general': { 'operation_type': 2, 'year': 2017}, - 'townsgeneral-operation_modification': [], - 'parcelsgeneral-operation_modification': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=base_ignored_steps ), FormData( "Operation: remove a parcel with no attached context record", form_datas={ - 'selec-operation_modification': {}, - 'general-operation_modification': { + 'selec': {}, + 'general': { 'operation_type': 2, 'year': 2017}, - 'townsgeneral-operation_modification': [], - 'parcelsgeneral-operation_modification': [], + 'townsgeneral': [], + 'parcelsgeneral': [], }, ignored=base_ignored_steps ), @@ -1305,33 +1311,40 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): 'history_modifier': self.get_default_user()} self.cr = ContextRecord.objects.create(**cr_data) + # diagnostic + self.ope_type = models.OperationType.objects.get( + txt_idx='prev_excavation') + self.form_datas[0].set('general', 'operation_type', self.ope_type.pk) + self.form_datas[1].set('general', 'operation_type', self.ope_type.pk) + self.form_datas[2].set('general', 'operation_type', self.ope_type.pk) + data = self.form_datas[0].form_datas data2 = self.form_datas[1].form_datas data3 = self.form_datas[2].form_datas - data['selec-operation_modification']['pk'] = operation.pk - data2['selec-operation_modification']['pk'] = operation.pk - data3['selec-operation_modification']['pk'] = operation.pk + data['selec']['pk'] = operation.pk + data2['selec']['pk'] = operation.pk + data3['selec']['pk'] = operation.pk town = self.create_towns( datas={'numero_insee': '67890', 'name': 'Twin Peaks'})[-1] towns = [{'town': town.pk}, {'town': init_town.pk}] - data['townsgeneral-operation_modification'] = towns - data2['townsgeneral-operation_modification'] = towns - data3['townsgeneral-operation_modification'] = towns + data['townsgeneral'] = towns + data2['townsgeneral'] = towns + data3['townsgeneral'] = towns parcel_data = { 'town': town.pk, 'year': 2017, 'section': 'S', 'parcel_number': '42'} - data['parcelsgeneral-operation_modification'].append(parcel_data) - data2['parcelsgeneral-operation_modification'].append(parcel_data) - data3['parcelsgeneral-operation_modification'].append(parcel_data) + data['parcelsgeneral'].append(parcel_data) + data2['parcelsgeneral'].append(parcel_data) + data3['parcelsgeneral'].append(parcel_data) parcel_data_2 = { 'town': init_parcel.town.pk, 'year': init_parcel.year or '', 'section': init_parcel.section, 'parcel_number': init_parcel.parcel_number} - data['parcelsgeneral-operation_modification'].append(parcel_data_2) + data['parcelsgeneral'].append(parcel_data_2) # no init parcel for data2 and data3 self.operation_number = models.Operation.objects.count() @@ -1342,7 +1355,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): test_object.operation_number) operation = models.Operation.objects.get( pk=test_object.operations[0].pk) - test_object.assertEqual(operation.operation_type.pk, 2) + 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) @@ -1354,7 +1368,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): test_object.operation_number) operation = models.Operation.objects.get( pk=test_object.operations[0].pk) - test_object.assertEqual(operation.operation_type.pk, 2) + 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) @@ -1374,7 +1389,8 @@ class OperationWizardModifTest(WizardTest, OperationInitTest, TestCase): test_object.operation_number) operation = models.Operation.objects.get( pk=test_object.operations[0].pk) - test_object.assertEqual(operation.operation_type.pk, 2) + 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(), |