From fa911907ad5c561a2a6176a66a0cd00a50d4fa6a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 11 Feb 2023 13:13:02 +0100 Subject: [PATCH] Tests YAML: check autorisations inscriptions --- tests/unit/cursus_but_geii_lyon.yaml | 3 +++ tests/unit/yaml_setup_but.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/unit/cursus_but_geii_lyon.yaml b/tests/unit/cursus_but_geii_lyon.yaml index 47e8645306..c1457d1a5f 100644 --- a/tests/unit/cursus_but_geii_lyon.yaml +++ b/tests/unit/cursus_but_geii_lyon.yaml @@ -135,6 +135,7 @@ Etudiants: code_valide: AJ decision_jury: AJ moy_ue: 9.00 + autorisations_inscription: [2] S2: notes_modules: # on joue avec les SAE seulement car elles sont "diagonales" "S2.1": 12.00 @@ -171,6 +172,7 @@ Etudiants: moy_rcue: 10.50 est_compensable: True decision_annee: RED + autorisations_inscription: [1] S1-red: notes_modules: # on joue avec les SAE seulement car elles sont "diagonales" "S1.1": 9.50 @@ -203,6 +205,7 @@ Etudiants: moy_rcue: 9.50 # la moyenne courante (et non enregistrée), donc pas 10.5 est_compensable: False decision_annee: ADM + autorisations_inscription: [2] geii43: prenom: etugeii43 civilite: M diff --git a/tests/unit/yaml_setup_but.py b/tests/unit/yaml_setup_but.py index c11e58288f..25633326c9 100644 --- a/tests/unit/yaml_setup_but.py +++ b/tests/unit/yaml_setup_but.py @@ -29,6 +29,7 @@ from app.models import ( UniteEns, ) from app.scodoc import sco_utils as scu +from app.scodoc import sco_pvjury def setup_formation_referentiel(formation: Formation, refcomp_infos: dict): @@ -292,6 +293,7 @@ def but_test_jury(formsemestre: FormSemestre, doc: dict): """Test jurys BUT Vérifie les champs de DecisionsProposeesAnnee et UEs """ + dpv = None for etud in formsemestre.etuds: deca = DecisionsProposeesAnnee(etud, formsemestre) doc_formsemestre = doc["Etudiants"][etud.nom]["formsemestres"][ @@ -302,3 +304,18 @@ def but_test_jury(formsemestre: FormSemestre, doc: dict): if "deca" in doc_formsemestre["attendu"]: deca_att = doc_formsemestre["attendu"]["deca"] but_compare_decisions_annee(deca, deca_att) + if "autorisations_inscription" in doc_formsemestre["attendu"]: + if dpv is None: # lazy load + dpv = sco_pvjury.dict_pvjury(formsemestre.id) + check_autorisations_inscription( + etud, dpv, doc_formsemestre["attendu"]["autorisations_inscription"] + ) + + +def check_autorisations_inscription( + etud: Identite, dpv: dict, autorisations_inscription_att: list[int] +): + """Vérifie que les autorisations d'inscription""" + dec_etud = dpv["decisions_dict"][etud.id] + autorisations_inscription = {d["semestre_id"] for d in dec_etud["autorisations"]} + assert autorisations_inscription == set(autorisations_inscription_att)