From 7d2d19f3a84afbf02a21bfccf57357c7db47ee79 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 18 Dec 2022 15:42:33 -0300 Subject: [PATCH] Tests unit BUT --- app/but/jury_but.py | 2 ++ app/but/jury_but_validation_auto.py | 9 +++++++-- app/static/css/scodoc.css | 2 +- tests/unit/cursus_but_gb.yaml | 20 ++++++++++++++++++-- tests/unit/test_but_jury.py | 6 ++++++ tests/unit/yaml_setup.py | 15 +++++++++------ 6 files changed, 43 insertions(+), 11 deletions(-) diff --git a/app/but/jury_but.py b/app/but/jury_but.py index d79bde0e9..05a902a31 100644 --- a/app/but/jury_but.py +++ b/app/but/jury_but.py @@ -341,6 +341,8 @@ class DecisionsProposeesAnnee(DecisionsProposees): if self.admis: self.codes = [sco_codes.ADM] + self.codes self.explanation = expl_rcues + # elif not self.jury_annuel: + # self.codes = [] # pas de décision annuelle sur semestres impairs elif self.inscription_etat != scu.INSCRIT: self.codes = [ sco_codes.DEM diff --git a/app/but/jury_but_validation_auto.py b/app/but/jury_but_validation_auto.py index 5c54c7b3a..918bd571e 100644 --- a/app/but/jury_but_validation_auto.py +++ b/app/but/jury_but_validation_auto.py @@ -15,8 +15,12 @@ from app.scodoc import sco_cache from app.scodoc.sco_exceptions import ScoValueError -def formsemestre_validation_auto_but(formsemestre: FormSemestre) -> int: +def formsemestre_validation_auto_but(formsemestre: FormSemestre, only_adm=True) -> int: """Calcul automatique des décisions de jury sur une année BUT. + Normalement, only_adm est True et on n'enregistre que les décisions ADM (de droit). + Si only_adm est faux, on enregistre la première décision proposée par ScoDoc + (mode à n'utiliser que pour les tests) + Returns: nombre d'étudiants "admis" """ if not formsemestre.formation.is_apc(): @@ -27,8 +31,9 @@ def formsemestre_validation_auto_but(formsemestre: FormSemestre) -> int: etud: Identite = Identite.query.get(etudid) deca = jury_but.DecisionsProposeesAnnee(etud, formsemestre) if deca.admis: # année réussie - deca.record_all() nb_admis += 1 + if deca.admis or not only_adm: + deca.record_all() db.session.commit() return nb_admis diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index 02c83f001..795901f03 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -138,7 +138,7 @@ div.about-logo { div.head_message { - margin-top: 2px; + margin-top: 12px; margin-bottom: 8px; padding: 5px; margin-left: auto; diff --git a/tests/unit/cursus_but_gb.yaml b/tests/unit/cursus_but_gb.yaml index 77eb5b81e..5dfb49ae0 100644 --- a/tests/unit/cursus_but_gb.yaml +++ b/tests/unit/cursus_but_gb.yaml @@ -143,8 +143,7 @@ Etudiants: attendu: # les codes jury que l'on doit vérifier deca: # decision année passage_de_droit: False - res_pair: None - codes: [ "RED", "..." ] + # jury S1, pas de décision annuelle decisions_ues: "UE 11": codes: [ "AJ", "..." ] @@ -167,6 +166,23 @@ Etudiants: "SAE22": 12 # UE22 ok, emporte le niveau par compensation "SAE23.SEE": 19 # UE23 SEE ok "SAE24.SEE": 12 # UE24 SEE ok, mais ne compense pas + attendu: + deca: + passage_de_droit: False + code: ["RED", "..."] + code_valide: "RED" + decisions_ues: + "UE 21": + codes: [ "AJ", "..." ] + code_valide: AJ + "UE 22": + code_valide: ADM + "UE 23 SEE": + code_valide: ADM + "UE 24 SEE": + code_valide: ADM + + S3: parcours: SEE Bbbbb: diff --git a/tests/unit/test_but_jury.py b/tests/unit/test_but_jury.py index c22f18d58..47cce49c4 100644 --- a/tests/unit/test_but_jury.py +++ b/tests/unit/test_but_jury.py @@ -5,6 +5,7 @@ from tests.unit import yaml_setup import app from app.but.jury_but import DecisionsProposeesAnnee +from app.but.jury_but_validation_auto import formsemestre_validation_auto_but from app.models import ( Formation, FormSemestre, @@ -34,6 +35,11 @@ def test_but_jury_GB(test_client): for formsemestre in FormSemestre.query: _check_deca(formsemestre) + # Saisie de toutes les décisions de jury + for formsemestre in FormSemestre.query.order_by(FormSemestre.semestre_id): + formsemestre_validation_auto_but(formsemestre, only_adm=False) + + # Vérifie résultats attendus: S1: FormSemestre = FormSemestre.query.filter_by(titre="S1_SEE").first() _test_but_jury(S1, doc) S2: FormSemestre = FormSemestre.query.filter_by(titre="S2_SEE").first() diff --git a/tests/unit/yaml_setup.py b/tests/unit/yaml_setup.py index 99c84e8d6..9b815c02c 100644 --- a/tests/unit/yaml_setup.py +++ b/tests/unit/yaml_setup.py @@ -348,12 +348,10 @@ def _check_decisions_ues( dec_ue = ues_d[0] if "codes" in dec_ue_att: _check_codes_jury(dec_ue.codes, dec_ue_att["codes"]) - if "moy_ue" in dec_ue_att: - assert dec_ue_att["moy_ue"] == dec_ue.moy_ue - if "moy_ue_with_cap" in dec_ue_att: - assert dec_ue_att["moy_ue_with_cap"] == dec_ue.moy_ue_with_cap - if "explanation" in dec_ue_att: - assert dec_ue_att["explanation"] == dec_ue.explanation + + for attr in ("moy_ue", "moy_ue_with_cap", "explanation", "code_valide"): + if attr in dec_ue_att: + assert getattr(dec_ue, attr) == dec_ue_att[attr] def compare_decisions_annee(deca: DecisionsProposeesAnnee, deca_att: dict): @@ -363,5 +361,10 @@ def compare_decisions_annee(deca: DecisionsProposeesAnnee, deca_att: dict): """ if "codes" in deca_att: _check_codes_jury(deca.codes, deca_att["codes"]) + + for attr in ("passage_de_droit", "code_valide"): + if attr in deca_att: + assert getattr(deca, attr) == deca_att[attr] + if "decisions_ues" in deca_att: _check_decisions_ues(deca.decisions_ues, deca_att["decisions_ues"])