summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index b4a798807..3e89273a0 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()
@@ -280,8 +287,9 @@ class ImportFindTest(ImportTest, TestCase):
'imported_images': SimpleUploadedFile(mcc_images.name,
mcc_images.read())}
post_dict = {'importer_type': MCC.pk, 'skip_lines': 1,
- "encoding": 'utf-8'}
- form = forms_common.NewImportForm(data=post_dict, files=file_dict)
+ "encoding": 'utf-8', "name": 'init_find_import'}
+ form = forms_common.NewImportForm(data=post_dict, files=file_dict,
+ user=self.user)
form.is_valid()
self.assertTrue(form.is_valid())
impt = form.save(self.ishtar_user)
@@ -305,6 +313,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