From 639941bc37dd1c12f8aa4f996c16093f63a7d336 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 21 Feb 2023 14:57:16 +0100 Subject: [PATCH] Fix: import formation xml --- app/scodoc/sco_formations.py | 4 ++-- tests/unit/test_formations.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index 5c53ef9b98..84a6039be6 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -293,11 +293,11 @@ def formation_import_xml(doc: str, import_tags=True, use_local_refcomp=False): referentiel_competence_id = _formation_retreive_refcomp(f_dict) f_dict["referentiel_competence_id"] = referentiel_competence_id # find new version number - formations = Formation.query.filter_by( + formations: list[Formation] = Formation.query.filter_by( acronyme=f_dict["acronyme"], titre=f_dict["titre"], dept_id=f_dict["dept_id"] ) if formations.count(): - version = max(f["version"] or 0 for f in formations) + version = max(f.version or 0 for f in formations) else: version = 0 f_dict["version"] = version + 1 diff --git a/tests/unit/test_formations.py b/tests/unit/test_formations.py index a3ac2d30d6..d521a009f2 100644 --- a/tests/unit/test_formations.py +++ b/tests/unit/test_formations.py @@ -335,6 +335,7 @@ def test_formations(test_client): def test_import_formation(test_client, filename="formation-exemple-1.xml"): """Test import/export formations""" G = sco_fake_gen.ScoFake(verbose=False) + # Lecture fichier XML local: with open( os.path.join(RESOURCES_DIR, "formations", filename),