126 lines
3.2 KiB
Python
126 lines
3.2 KiB
Python
import random
|
|
|
|
# La variable context est définie par le script de lancement
|
|
# l'affecte ainsi pour évietr les warnins pylint:
|
|
context = context # pylint: disable=undefined-variable
|
|
REQUEST = REQUEST # pylint: disable=undefined-variable
|
|
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
|
import sco_abs
|
|
import sco_abs_views
|
|
import sco_abs_notification
|
|
import ZAbsences
|
|
|
|
G = sco_fake_gen.ScoFake(context.Notes)
|
|
G.verbose = False
|
|
|
|
# --- Création d'étudiants
|
|
etud = G.create_etud(code_nip=None)
|
|
|
|
# --- Création d'une formation
|
|
f = G.create_formation(acronyme="")
|
|
ue = G.create_ue(formation_id=f["formation_id"], acronyme="TST1", titre="ue test")
|
|
mat = G.create_matiere(ue_id=ue["ue_id"], titre="matière test")
|
|
mod = G.create_module(
|
|
matiere_id=mat["matiere_id"],
|
|
code="TSM1",
|
|
coefficient=1.0,
|
|
titre="module test",
|
|
ue_id=ue["ue_id"], # faiblesse de l'API
|
|
formation_id=f["formation_id"], # faiblesse de l'API
|
|
)
|
|
|
|
# --- Mise place d'un semestre
|
|
sem = G.create_formsemestre(
|
|
formation_id=f["formation_id"],
|
|
semestre_id=1,
|
|
date_debut="01/01/2021",
|
|
date_fin="30/06/2021",
|
|
)
|
|
|
|
mi = G.create_moduleimpl(
|
|
module_id=mod["module_id"],
|
|
formsemestre_id=sem["formsemestre_id"],
|
|
responsable_id="bach",
|
|
)
|
|
|
|
# --- Inscription des étudiants
|
|
G.inscrit_etudiant(sem, etud)
|
|
|
|
# --- Saisie absences
|
|
etudid = etud["etudid"]
|
|
|
|
for debut, fin, demijournee in [
|
|
("15/01/2021", "15/01/2021", 1),
|
|
("18/01/2021", "18/01/2021", 0),
|
|
("19/01/2021", "19/01/2021", 2),
|
|
("22/01/2021", "22/01/2021", 1),
|
|
]:
|
|
sco_abs_views.doSignaleAbsence(
|
|
context.Absences,
|
|
datedebut=debut,
|
|
datefin=fin,
|
|
demijournee=demijournee,
|
|
etudid=etudid,
|
|
REQUEST=REQUEST,
|
|
)
|
|
|
|
|
|
# --- Justification de certaines absences
|
|
|
|
for debut, fin, demijournee in [
|
|
("15/01/2021", "15/01/2021", 1),
|
|
("18/01/2021", "18/01/2021", 0),
|
|
("19/01/2021", "19/01/2021", 2),
|
|
]:
|
|
sco_abs_views.doJustifAbsence(
|
|
context.Absences,
|
|
datedebut=debut,
|
|
datefin=fin,
|
|
demijournee=demijournee,
|
|
etudid=etudid,
|
|
REQUEST=REQUEST,
|
|
)
|
|
|
|
|
|
# --- Utilisation de get_abs_count() de sco_abs
|
|
|
|
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
|
|
|
|
|
# --- Utilisation de CountAbs() de ZAbsences
|
|
|
|
nb_abs2 = context.Absences.CountAbs(etudid=etudid, debut="01/01/2021", fin="06/30/2021")
|
|
nb_absj2 = context.Absences.CountAbsJust(
|
|
etudid=etudid, debut="01/01/2021", fin="06/30/2021"
|
|
)
|
|
|
|
assert nbabs == nb_abs2 == 5
|
|
assert nbabsjust == nb_absj2 == 4
|
|
|
|
# --- Suppression d'absence
|
|
|
|
_ = sco_abs_views.doAnnuleAbsence(
|
|
context.Absences, "19/01/2021", "19/01/2021", 2, etudid=etudid, REQUEST=REQUEST
|
|
)
|
|
|
|
# --- Vérification
|
|
|
|
new_nbabs, _ = sco_abs.get_abs_count(etudid, sem)
|
|
new_nbabs2 = context.Absences.CountAbs(
|
|
etudid=etudid, debut="01/01/2021", fin="06/30/2021"
|
|
)
|
|
|
|
print(new_nbabs)
|
|
print(new_nbabs2)
|
|
|
|
assert new_nbabs == new_nbabs2
|
|
|
|
|
|
"""
|
|
Commentaire :
|
|
|
|
CountAbs de ZAbsence ----> OK
|
|
CountAbs de sco_abs_view ----> bug
|
|
|
|
Peut être du au fait que la fonction getAbsSemEtud ne se met pas à jour par rapport aux absences supprimés.
|
|
""" |