test unitaire: test_but_assoc_refcomp

This commit is contained in:
Emmanuel Viennet 2022-10-29 15:42:03 +02:00 committed by iziram
parent eefdd5458e
commit 93e54982b6
2 changed files with 30 additions and 3 deletions

View File

@ -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

View File

@ -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