summaryrefslogtreecommitdiff
path: root/archaeological_context_records/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r--archaeological_context_records/tests.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index 852cd3aa7..1716920e9 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -224,6 +224,49 @@ class ImportContextRecordTest(ImportTest, TestCase):
self.assertEqual(current_nb, 4)
"""
+ def test_qfield_import_cr(self):
+ """
+ :function: Try the importation of a context record link to QField
+ """
+ # Definition of the path to test importer data for GIS data
+ root = settings.LIB_BASE_PATH + "archaeological_context_records/tests/"
+ filename = root + "qfield-ue-test.zip"
+ self.restore_serialized(filename)
+ # Uses of a class in ishtar_commons.model_import to retrieve a model via its slug (?)
+ imp_type = ImporterType.objects.get(slug="qfield-ue-test") # Change the name with the slug of the importeur !!!
+ # Opening of the CSV
+ with open(root + "qfield-importeur-data.csv", "rb") as imp_file :
+ file_dict = {
+ "imported_file": SimpleUploadedFile(imp_file.name, imp_file.read())
+ }
+ post_dict = {
+ "importer_type": imp_type.pk,
+ "name": "find_geo_import",
+ "encoding": "utf-8",
+ "skip_lines": 1,
+ "csv_sep": ",",
+ }
+ # Preparation of the data import
+ form = forms_common.NewImportGISForm(
+ data=post_dict, files=file_dict, user=self.user
+ )
+ self.assertTrue(form.is_valid())
+ impt = form.save(self.ishtar_user)
+ # Initialisation de l'import
+ impt.initialize()
+ # Creation of an operation for the importation
+ ope, __ = models.Operation.objects.get_or_create(
+ code_patriarche="OP",
+ operation_type=models_ope.OperationType.objects.all()[0])
+
+ # Getting referential values (nb objects, containers,docs, etc.)
+ nb_cr = models.ContextRecord.objects.count()
+ # Beggining of importation
+ impt.importation()
+ # Getting values after modifications
+ self.assertEqual(models.ContextRecord.objects.count(), nb_cr + 1)
+
+
class ContextRecordInit(OperationInitTest):
def create_context_record(self, data=None, user=None, force=False):