diff options
author | Thomas André <thomas.andre@iggdrasil.net> | 2025-04-14 08:42:38 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-07-29 08:49:03 +0200 |
commit | af13ebbe3d2314cef33bd8f9e372f62518db4465 (patch) | |
tree | b0078ec33a98b60862c966cab4e8d5c48f2ddd54 /archaeological_context_records/tests.py | |
parent | e027200e47ed93b25e2cca5f3392ba7879ad69a1 (diff) | |
download | Ishtar-af13ebbe3d2314cef33bd8f9e372f62518db4465.tar.bz2 Ishtar-af13ebbe3d2314cef33bd8f9e372f62518db4465.zip |
First tests for the uses of QField project with Ishtar datas and their importation
Diffstat (limited to 'archaeological_context_records/tests.py')
-rw-r--r-- | archaeological_context_records/tests.py | 43 |
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): |