Assiduités: test_sco_basic #692

This commit is contained in:
iziram 2023-09-05 08:41:40 +02:00
parent 0c166d90d7
commit 36f7d0396a
2 changed files with 39 additions and 18 deletions

View File

@ -74,9 +74,11 @@ class Identite(db.Model):
)
# Relations avec les assiduites et les justificatifs
assiduites = db.relationship("Assiduite", back_populates="etudiant", lazy="dynamic")
assiduites = db.relationship(
"Assiduite", back_populates="etudiant", lazy="dynamic", cascade="all, delete"
)
justificatifs = db.relationship(
"Justificatif", back_populates="etudiant", lazy="dynamic"
"Justificatif", back_populates="etudiant", lazy="dynamic", cascade="all, delete"
)
def __repr__(self):

View File

@ -23,15 +23,18 @@ import app
from app import db
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre
from app.models import FormSemestre, Assiduite, Justificatif
from app.scodoc import sco_formsemestre
from app.scodoc import sco_bulletins
from app.scodoc import codes_cursus
from app.scodoc import sco_assiduites as scass
from app.scodoc import sco_evaluations
from app.scodoc import sco_evaluation_db
from app.scodoc import sco_formsemestre_validation
from app.scodoc import sco_cursus_dut
from app.scodoc import sco_saisie_notes
from app.scodoc.sco_utils import EtatAssiduite, EtatJustificatif, localize_datetime
from app.models.assiduites import compute_assiduites_justified
DEPT = TestConfig.DEPT_TEST
@ -186,21 +189,10 @@ def run_sco_basic(verbose=False) -> FormSemestre:
# -----------------------
etudid = etuds[0]["etudid"]
# XXX TODO-ASSIDUITE
# _ = sco_abs_views.doSignaleAbsence(
# "15/01/2020", "18/01/2020", demijournee=2, etudid=etudid
# )
# _ = sco_abs_views.doJustifAbsence(
# "17/01/2020",
# "18/01/2020",
# demijournee=2,
# etudid=etudid,
# )
# nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
# assert nbabs == 6, f"incorrect nbabs ({nbabs})"
# assert nbabsjust == 2, f"incorrect nbabsjust ({nbabsjust})"
_signal_absences_justificatifs(etudid)
nbabs, nbabsjust = scass.get_assiduites_count(etudid, sem)
assert nbabs == 6, f"incorrect nbabs ({nbabs})"
assert nbabsjust == 2, f"incorrect nbabsjust ({nbabsjust})"
# --- Permission saisie notes et décisions de jury, avec ou sans démission ou défaillance
# on n'a pas encore saisi de décisions
@ -251,3 +243,30 @@ def run_sco_basic(verbose=False) -> FormSemestre:
)
assert q.count() == 0
return formsemestre
def _signal_absences_justificatifs(etudid: int):
etud: Identite = Identite.query.get(etudid)
db.session.commit()
for i in range(15, 18):
db.session.add(
Assiduite.create_assiduite(
etud=etud,
date_debut=localize_datetime(datetime.datetime(2020, 1, i, 8, 0)),
date_fin=localize_datetime(datetime.datetime(2020, 1, i, 18, 0)),
etat=EtatAssiduite.ABSENT,
)
)
db.session.commit()
justif: Justificatif = Justificatif.create_justificatif(
etud=etud,
date_debut=localize_datetime(datetime.datetime(2020, 1, 17, 8, 0)),
date_fin=localize_datetime(datetime.datetime(2020, 1, 17, 18, 0)),
etat=EtatJustificatif.VALIDE,
)
db.session.add(justif)
compute_assiduites_justified(
etud.etudid,
[justif],
)
db.session.commit()