Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (import) : hide jdd selection form #3206

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def upgrade():
"fr_label": "Identifiant JDD (UUID)",
"mandatory": False,
"autogenerated": False,
"display": True,
"display": False,
"mnemonique": None,
"source_field": "src_unique_dataset_id",
"dest_field": "unique_dataset_id",
Expand Down
23 changes: 19 additions & 4 deletions backend/geonature/tests/imports/fixtures.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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)
)

Expand All @@ -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)
4 changes: 3 additions & 1 deletion backend/geonature/tests/imports/test_imports_occhab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion backend/geonature/tests/imports/test_imports_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ def change_id_list_conf(monkeypatch, sample_taxhub_list):


@pytest.mark.usefixtures(
"client_class", "temporary_transaction", "celery_eager", "default_synthese_destination"
"client_class",
"temporary_transaction",
"celery_eager",
"default_synthese_destination",
"display_unique_dataset_id",
)
class TestImportsSynthese:
def test_import_permissions(self, g_permissions, synthese_destination):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def upgrade():
"fr_label": "Identifiant JDD (UUID)",
"mandatory": False,
"autogenerated": False,
"display": True,
"display": False,
"mnemonique": None,
"source_field": "src_unique_dataset_id",
"dest_field": "unique_dataset_id",
Expand Down
Loading