2021-07-02 12:34:44 +02:00
|
|
|
""" creation de 10 étudiants, formation, semestre, ue, module, absences le matin, l'apres midi, la journée compléte
|
|
|
|
et justification d'absences, supression d'absences, création d'une liste etat absences, creation d'un groupe afin
|
|
|
|
de tester la fonction EtatAbsencesGroupes
|
|
|
|
|
|
|
|
Fonctions de l'API utilisé :
|
|
|
|
- doSignaleAbsence
|
|
|
|
- doAnnuleAbsence
|
|
|
|
- doJustifAbsence
|
|
|
|
- get_partition_groups
|
|
|
|
- get_partitions_list
|
2021-07-19 19:53:01 +02:00
|
|
|
- sco_abs.get_abs_count(etudid, sem)
|
2021-07-02 12:34:44 +02:00
|
|
|
- ListeAbsEtud
|
|
|
|
- partition_create
|
|
|
|
- createGroup
|
|
|
|
- set_group
|
|
|
|
- EtatAbsenceGr
|
|
|
|
- AddBilletAbsence
|
|
|
|
- listeBilletsEtud
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
etuds = [G.create_etud(code_nip=None) for _ in range(10)]
|
|
|
|
|
|
|
|
# --- 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
|
|
|
|
for etud in etuds:
|
|
|
|
G.inscrit_etudiant(sem, etud)
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
# --- Création d'une évaluation
|
2021-07-02 12:34:44 +02:00
|
|
|
e = G.create_evaluation(
|
|
|
|
moduleimpl_id=mi["moduleimpl_id"],
|
|
|
|
jour="22/01/2021",
|
|
|
|
description="evaluation test",
|
|
|
|
coefficient=1.0,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# --- Saisie absences
|
|
|
|
etudid = etuds[0]["etudid"]
|
|
|
|
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"15/01/2021",
|
|
|
|
"15/01/2021",
|
|
|
|
demijournee=1,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"18/01/2021",
|
|
|
|
"18/01/2021",
|
|
|
|
demijournee=0,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"19/01/2021",
|
|
|
|
"19/01/2021",
|
|
|
|
demijournee=2,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doSignaleAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"22/01/2021",
|
|
|
|
"22/01/2021",
|
|
|
|
demijournee=1,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Justification de certaines absences
|
|
|
|
|
|
|
|
_ = sco_abs_views.doJustifAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"15/01/2021",
|
|
|
|
"15/01/2021",
|
|
|
|
demijournee=1,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doJustifAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"18/01/2021",
|
|
|
|
"18/01/2021",
|
|
|
|
demijournee=0,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
_ = sco_abs_views.doJustifAbsence(
|
|
|
|
context.Absences,
|
|
|
|
"19/01/2021",
|
|
|
|
"19/01/2021",
|
|
|
|
demijournee=2,
|
|
|
|
etudid=etudid,
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
|
|
|
|
|
|
|
# --- Test
|
|
|
|
|
|
|
|
b = sco_abs.is_work_saturday(context.Absences)
|
2021-07-19 19:53:01 +02:00
|
|
|
assert b == 0 # samedi ne sont pas compris
|
|
|
|
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
|
|
|
assert (
|
|
|
|
nbabs == 5
|
|
|
|
) # l'étudiant a été absent le 15 (apres midi) , (16 et 17 we), 18 (matin) et 19 janvier (matin et apres midi), et 22 (matin)
|
|
|
|
assert nbabsjust == 4 # l'étudiant justifie ses abs du 15, 18 et 19
|
|
|
|
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
# + vérification à l'aide de ScoDoc WEB : ok!
|
|
|
|
|
|
|
|
# --- Supression d'une absence et d'une justification
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
_ = sco_abs_views.doAnnuleAbsence(
|
|
|
|
context.Absences, "19/01/2021", "19/01/2021", 2, etudid=etudid, REQUEST=REQUEST
|
|
|
|
)
|
|
|
|
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, sem)
|
|
|
|
print(nbabs) # lors du print cela affiche 5 or cela devrait afficher 3
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
# assert nbabs == 3
|
|
|
|
# + vérification à l'aide de ScoDoc WEB : il y a bien plus que 3 abs, 2 justifiés et 1 non justifié.
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --- supression d'une justification pas encore disponible à l'aide de python.
|
|
|
|
|
|
|
|
|
|
|
|
# --- Création d'une liste d'abs
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
liste_abs = sco_abs_views.ListeAbsEtud(
|
|
|
|
context.Absences, etudid, format="json", absjust_only=1, REQUEST=REQUEST
|
|
|
|
)
|
|
|
|
liste_abs2 = sco_abs_views.ListeAbsEtud(
|
|
|
|
context.Absences, etudid, format="json", REQUEST=REQUEST
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
load_liste_abs = json.loads(liste_abs)
|
|
|
|
load_liste_abs2 = json.loads(liste_abs2)
|
|
|
|
|
|
|
|
assert len(load_liste_abs2) == 1
|
|
|
|
assert len(load_liste_abs) == 2
|
|
|
|
assert load_liste_abs2[0]["ampm"] == "1"
|
|
|
|
assert load_liste_abs2[0]["datedmy"] == "22/01/2021"
|
|
|
|
assert load_liste_abs2[0]["exams"] == mod["code"]
|
|
|
|
# absjust_only -> seulement les abs justifiés
|
|
|
|
|
|
|
|
|
|
|
|
# --- Création d'un groupe
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
_ = sco_groups.partition_create(
|
|
|
|
context.Scolarite,
|
|
|
|
formsemestre_id=sem["formsemestre_id"],
|
|
|
|
partition_name="Eleve",
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
li1 = sco_groups.get_partitions_list(context.Scolarite, sem["formsemestre_id"])
|
2021-07-29 16:31:15 +02:00
|
|
|
_ = sco_groups.createGroup(context.Scolarite, li1[0]["partition_id"], "Groupe 1")
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
# --- Affectation des élèves dans des groupes
|
|
|
|
|
|
|
|
li_grp1 = sco_groups.get_partition_groups(context.Scolarite, li1[0])
|
2021-07-19 19:53:01 +02:00
|
|
|
for etud in etuds:
|
2021-07-02 12:34:44 +02:00
|
|
|
sco_groups.set_group(context.Scolarite, etud["etudid"], li_grp1[0]["group_id"])
|
|
|
|
|
|
|
|
# --- Test de EtatAbsencesGroupes
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
grp1_abs = context.Absences.EtatAbsencesGr(
|
|
|
|
group_ids=[li_grp1[0]["group_id"]],
|
|
|
|
debut="01/01/2021",
|
|
|
|
fin="30/06/2021",
|
|
|
|
format="json",
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
load_grp1_abs = json.loads(grp1_abs)
|
|
|
|
|
|
|
|
assert len(load_grp1_abs) == 10
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
tab_id = [] # tab des id present dans load_grp1_abs
|
|
|
|
for un_etud in load_grp1_abs:
|
2021-07-02 12:34:44 +02:00
|
|
|
tab_id.append(un_etud["etudid"])
|
2021-07-19 19:53:01 +02:00
|
|
|
|
|
|
|
for (
|
|
|
|
etud
|
|
|
|
) in (
|
|
|
|
etuds
|
|
|
|
): # verification si tous les etudiants sont present dans la liste du groupe d'absence
|
2021-07-02 12:34:44 +02:00
|
|
|
assert etud["etudid"] in tab_id
|
|
|
|
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
for un_etud in load_grp1_abs:
|
|
|
|
if un_etud["etudid"] == etudid:
|
2021-07-02 12:34:44 +02:00
|
|
|
assert un_etud["nbabs"] == "3"
|
|
|
|
assert un_etud["nbjustifs_noabs"] == "2"
|
|
|
|
assert un_etud["nbabsjust"] == "2"
|
|
|
|
assert un_etud["nbabsnonjust"] == "1"
|
|
|
|
assert un_etud["nomprenom"] == etuds[0]["nomprenom"]
|
|
|
|
|
2021-07-19 19:53:01 +02:00
|
|
|
# --- Création de billets
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
b1 = context.Absences.AddBilletAbsence(
|
2021-07-19 19:53:01 +02:00
|
|
|
begin="2021-01-22 00:00",
|
|
|
|
end="2021-01-22 23:59",
|
|
|
|
etudid=etudid,
|
|
|
|
description="abs du 22",
|
|
|
|
justified=False,
|
|
|
|
code_nip=etuds[0]["code_nip"],
|
|
|
|
code_ine=etuds[0]["code_ine"],
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
b2 = context.Absences.AddBilletAbsence(
|
2021-07-19 19:53:01 +02:00
|
|
|
begin="2021-01-15 00:00",
|
|
|
|
end="2021-01-15 23:59",
|
|
|
|
etudid=etudid,
|
|
|
|
description="abs du 15",
|
|
|
|
code_nip=etuds[0]["code_nip"],
|
|
|
|
code_ine=etuds[0]["code_ine"],
|
|
|
|
REQUEST=REQUEST,
|
|
|
|
)
|
2021-07-02 12:34:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
li_bi = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
|
|
|
load_li_bi = json.loads(li_bi)
|
|
|
|
|
|
|
|
assert len(load_li_bi) == 2
|
|
|
|
assert load_li_bi[1]["description"] == "abs du 22"
|
|
|
|
|
|
|
|
"""
|
|
|
|
Commentaire :
|
|
|
|
|
|
|
|
Parametre demijournee ne prend pas en compte les strings ---> pb régler.
|
|
|
|
|
|
|
|
La suppression de justification ne peut pas se faire directement en interractif à l'aide de python.
|
|
|
|
|
|
|
|
La fonction CountAbs ne met pas à jour le nombre après supression des absences. ---> (cf : test_CountAbs.py)
|
|
|
|
|
|
|
|
"""
|