diff --git a/backend/geonature/tests/imports/fixtures.py b/backend/geonature/tests/imports/fixtures.py index bac540b3f7..a28ebe84d5 100644 --- a/backend/geonature/tests/imports/fixtures.py +++ b/backend/geonature/tests/imports/fixtures.py @@ -1,11 +1,11 @@ import pytest from flask import g -from sqlalchemy import select +import sqlalchemy as sa from geonature.core.gn_commons.models import TModules from geonature.utils.env import db -from geonature.core.imports.models import Destination +from geonature.core.imports.models import BibFields, Destination @pytest.fixture(scope="session") @@ -41,17 +41,20 @@ def default_synthese_destination(app, default_destination, synthese_destination) @pytest.fixture(scope="session") def list_all_module_dest_code(): module_code_dest = db.session.scalars( - select(TModules.module_code).join(Destination, Destination.id_module == TModules.id_module) + sa.select(TModules.module_code).join( + Destination, Destination.id_module == TModules.id_module + ) ).all() return module_code_dest @pytest.fixture(scope="session") def all_modules_destination(list_all_module_dest_code): + dict_modules_dest = {} for module_code in list_all_module_dest_code: - query = select(Destination).filter( + query = sa.select(Destination).filter( Destination.module.has(TModules.module_code == module_code) ) @@ -60,3 +63,15 @@ def all_modules_destination(list_all_module_dest_code): dict_modules_dest[module_code] = result return dict_modules_dest + + +@pytest.fixture() +def display_unique_dataset_id(): + """ + This fixture is temporary and must be removed when the UUID of a JDD can be mapped in the + fieldmapping step ! + """ + query = ( + sa.update(BibFields).where(BibFields.name_field == "unique_dataset_id").values(display=True) + ) + db.session.execute(query) diff --git a/backend/geonature/tests/imports/test_imports_occhab.py b/backend/geonature/tests/imports/test_imports_occhab.py index dbee7ac133..6dbb2f8ef4 100644 --- a/backend/geonature/tests/imports/test_imports_occhab.py +++ b/backend/geonature/tests/imports/test_imports_occhab.py @@ -84,7 +84,9 @@ def contentmapping(occhab_destination): @pytest.fixture() -def uploaded_import(client, users, datasets, station, habitat, import_file_name): +def uploaded_import( + client, users, datasets, station, habitat, import_file_name, display_unique_dataset_id +): with open(test_files_path / import_file_name, "rb") as f: test_file_line_count = sum(1 for line in f) - 1 # remove headers f.seek(0) diff --git a/backend/geonature/tests/imports/test_imports_synthese.py b/backend/geonature/tests/imports/test_imports_synthese.py index 09a4eed49a..96cc490356 100644 --- a/backend/geonature/tests/imports/test_imports_synthese.py +++ b/backend/geonature/tests/imports/test_imports_synthese.py @@ -118,7 +118,7 @@ def autogenerate(): @pytest.fixture() -def import_dataset(datasets, import_file_name): +def import_dataset(datasets, import_file_name, display_unique_dataset_id): ds = datasets["own_dataset"] if import_file_name == "nomenclatures_file.csv": previous_data_origin = ds.nomenclature_data_origin