summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/fixtures/initial_data-fr.json6
-rw-r--r--archaeological_finds/tests.py29
-rw-r--r--archaeological_finds/tests/MCC-finds-example.csv10
-rw-r--r--archaeological_finds/tests/images.zipbin0 -> 1696 bytes
4 files changed, 34 insertions, 11 deletions
diff --git a/archaeological_finds/fixtures/initial_data-fr.json b/archaeological_finds/fixtures/initial_data-fr.json
index 1b26d8cd2..426a3800a 100644
--- a/archaeological_finds/fixtures/initial_data-fr.json
+++ b/archaeological_finds/fixtures/initial_data-fr.json
@@ -596,7 +596,7 @@
"comment": "",
"available": true,
"txt_idx": "recond",
- "label": "A reconditionner"
+ "label": "\u00c0 reconditionner"
}
},
{
@@ -606,7 +606,7 @@
"comment": "",
"available": true,
"txt_idx": "to_restaur",
- "label": "A restaurer"
+ "label": "\u00c0 restaurer"
}
},
{
@@ -616,7 +616,7 @@
"comment": "",
"available": true,
"txt_idx": "to_stab",
- "label": "A stabiliser"
+ "label": "\u00c0 stabiliser"
}
},
{
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index f75e9cfa3..c17e440b1 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -20,7 +20,8 @@
from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
-from ishtar_common.models import ImporterType, IshtarUser
+from ishtar_common.models import ImporterType, IshtarUser, ImporterColumn,\
+ FormaterType, ImportTarget
from archaeological_finds import models
@@ -42,12 +43,26 @@ class ImportFindTest(ImportContextRecordTest):
self.testMCCImportContextRecords(test=False)
old_nb = models.BaseFind.objects.count()
+ old_nb_find = models.Find.objects.count()
MCC = ImporterType.objects.get(name=u"MCC - Mobilier")
+
+ col = ImporterColumn.objects.create(col_number=25,
+ importer_type_id=MCC.pk)
+ formater = FormaterType.objects.filter(
+ formater_type='FileFormater').all()[0]
+ ImportTarget.objects.create(target='find__image',
+ formater_type_id=formater.pk,
+ column_id=col.pk)
mcc_file = open(
settings.ROOT_PATH +
'../archaeological_finds/tests/MCC-finds-example.csv', 'rb')
+ mcc_images = open(
+ settings.ROOT_PATH +
+ '../archaeological_finds/tests/images.zip', 'rb')
file_dict = {'imported_file': SimpleUploadedFile(mcc_file.name,
- mcc_file.read())}
+ mcc_file.read()),
+ '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,
@@ -60,15 +75,23 @@ class ImportFindTest(ImportContextRecordTest):
# doing manual connections
ceram = models.MaterialType.objects.get(txt_idx='ceramic').pk
+ glass = models.MaterialType.objects.get(txt_idx='glass').pk
self.setTargetKey('find__material_types', 'terre-cuite', ceram)
+ self.setTargetKey('find__material_types', 'verre', glass)
impt.importation()
if not test:
return
# new finds has now been imported
current_nb = models.BaseFind.objects.count()
- self.assertTrue(current_nb == (old_nb + 4))
+ self.assertEqual(current_nb, (old_nb + 4))
+ current_nb = models.Find.objects.count()
+ self.assertEqual(current_nb, (old_nb_find + 4))
self.assertEqual(
models.Find.objects.filter(material_types__pk=ceram).count(), 4)
+ self.assertEqual(
+ models.Find.objects.filter(material_types__pk=glass).count(), 1)
+ images = [f.image for f in models.Find.objects.all() if f.image.name]
+ self.assertEqual(len(images), 1)
class FindInit(ContextRecordInit):
diff --git a/archaeological_finds/tests/MCC-finds-example.csv b/archaeological_finds/tests/MCC-finds-example.csv
index 13340b9aa..86a572657 100644
--- a/archaeological_finds/tests/MCC-finds-example.csv
+++ b/archaeological_finds/tests/MCC-finds-example.csv
@@ -1,5 +1,5 @@
-code OA,numero INSEE commune,identifiant parcelle,identifiant UE,identifiant materiel,objet lot,partage,composite,matiere,type,determination,numero contenant,nombre fragment,poids,unite poids,date decouverte,etat sanitaire,type preservation a envisager,commentaire,chronologie,localisation topographique,interet particulier,description,remontage
-4200,75101,XXXX,HC,1,lot,non,,terre cuite,céramique,sfq,1,76,4040,g,,sais pas,,Blah,med,,,,
-4200,75101,XXXX,H.-C.,1,lot,non,,terre cuite,céramique,qsdfsqfd,1,56,2280,g,,,,,med,,,,
-4200,59350,YY55,US17,1,lot,non,,terre cuite,céramique,sqfdsq,2,44,5210,g,,stable,,,GR,,,,
-4200,59350,YY55,US17,2,lot,non,,terre cuite,céramique,sqfdsq,45,43,1500,g,,,,,,,,,
+code OA,numero INSEE commune,identifiant parcelle,identifiant UE,identifiant materiel,objet lot,partage,composite,matiere,type,determination,numero contenant,nombre fragment,poids,unite poids,date decouverte,etat sanitaire,type preservation a envisager,commentaire,chronologie,localisation topographique,interet particulier,description,remontage,photo
+4200,75101,XXXX,HC,1,lot,non,,terre cuite,céramique,sfq,1,76,4040,g,,sais pas,,Blah,med,,,,,
+4200,75101,XXXX,H.-C.,1,lot,non,,terre cuite,céramique,qsdfsqfd,1,56,2280,g,,,,,med,,,,,
+4200,59350,YY55,US17,1,lot,non,,terre cuite,céramique,sqfdsq,2,44,5210,g,,stable,,,GR,,,,,
+4200,59350,YY55,US17,2,lot,non,,terre cuite & verre,céramique,sqfdsq,45,43,1500,g,,,,,,,,,,image-1.jpg
diff --git a/archaeological_finds/tests/images.zip b/archaeological_finds/tests/images.zip
new file mode 100644
index 000000000..13b2680e7
--- /dev/null
+++ b/archaeological_finds/tests/images.zip
Binary files differ