diff options
Diffstat (limited to 'archaeological_finds/tests.py')
| -rw-r--r-- | archaeological_finds/tests.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index b4a798807..a128b05ff 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -68,8 +68,11 @@ class FindInit(ContextRecordInit): self.base_finds = [] default = {'label': "Base find"} - if not data_base.get('history_modifier'): - data_base['history_modifier'] = self.get_default_user() + if not data_base.get('history_modifier') or not data_base[ + 'history_modifier'].pk: + user = self.get_default_user() + user.save() + data_base['history_modifier'] = user if force or not data_base.get('context_record'): data_base['context_record'] = self.get_default_context_record( force=force) @@ -203,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 } @@ -233,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() @@ -305,6 +312,22 @@ class ImportFindTest(ImportTest, TestCase): images = [f.image for f in models.Find.objects.all() if f.image.name] self.assertEqual(len(images), 1) + # check index + bfs = list(models.BaseFind.objects.order_by("-pk").all()) + for idx in range(4): + bf = bfs[idx] + expected_index = 4 - idx + self.assertEqual( + bf.index, expected_index, + "Bad index for imported base find: {} where {} is " + "expected".format(bf.index, expected_index)) + f = bf.find.all()[0] + self.assertEqual( + f.index, expected_index, + "Bad index for imported find: {} where {} is expected".format( + f.index, expected_index + )) + class FindTest(FindInit, TestCase): fixtures = FIND_FIXTURES |
