1
0
forked from ScoDoc/ScoDoc

Tests unit BUT

This commit is contained in:
Emmanuel Viennet 2022-12-18 15:42:33 -03:00 committed by iziram
parent 882d131837
commit 7d2d19f3a8
6 changed files with 43 additions and 11 deletions

View File

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

View File

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

View File

@ -138,7 +138,7 @@ div.about-logo {
div.head_message {
margin-top: 2px;
margin-top: 12px;
margin-bottom: 8px;
padding: 5px;
margin-left: auto;

View File

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

View File

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

View File

@ -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"])