From 93e54982b641318ce7fa5afa43c802a7b83b953c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 29 Oct 2022 15:42:03 +0200 Subject: [PATCH] test unitaire: test_but_assoc_refcomp --- app/models/__init__.py | 7 ++++--- tests/unit/test_refcomp.py | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/models/__init__.py b/app/models/__init__.py index c7a183ec..23c677c8 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -72,11 +72,12 @@ from app.models.validations import ( from app.models.preferences import ScoPreference from app.models.but_refcomp import ( - ApcReferentielCompetences, - ApcCompetence, - ApcSituationPro, ApcAppCritique, + ApcCompetence, + ApcNiveau, ApcParcours, + ApcReferentielCompetences, + ApcSituationPro, ) from app.models.but_validations import ApcValidationAnnee, ApcValidationRCUE diff --git a/tests/unit/test_refcomp.py b/tests/unit/test_refcomp.py index 2e56ed3c..b09b9775 100644 --- a/tests/unit/test_refcomp.py +++ b/tests/unit/test_refcomp.py @@ -17,6 +17,7 @@ from app.models.but_refcomp import ( ApcSituationPro, ApcNiveau, ) +from app.models.formations import Formation from tests.unit import setup @@ -58,3 +59,28 @@ def test_but_assoc_ue_parcours(test_client): assert ue.niveau_competence == niveau assert len(niveau.ues) == 1 assert niveau.ues[0] == ue + + +def test_but_assoc_refcomp(test_client): + """Association formation / référentiel de compétences""" + dept_id = models.Departement.query.first().id + G, formation_id, (ue1_id, ue2_id, ue3_id), module_ids = setup.build_formation_test() + formation: Formation = Formation.query.get(formation_id) + assert formation is not None + ref_comp: ApcReferentielCompetences = orebut_import_refcomp(REF_RT_XML, dept_id) + formation.referentiel_competence_id = ref_comp.id + db.session.add(formation) + db.session.commit() + ue = UniteEns.query.get(ue1_id) + niveau = ( + ApcNiveau.query.filter_by(annee="BUT1") + .join(ApcCompetence) + .filter_by(referentiel_id=ref_comp.id) + .first() + ) + assert niveau is not None + ue.niveau_competence_id = niveau.id + db.session.add(ue) + db.session.commit() + formation.refcomp_desassoc() + assert ue.niveau_competence_id is None