ajout de nouveaux tests
This commit is contained in:
parent
01820b5a91
commit
2c7d55713a
59
scotests/test_AnnuleAbsencesDatesNoJust.py
Executable file
59
scotests/test_AnnuleAbsencesDatesNoJust.py
Executable file
@ -0,0 +1,59 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -
|
||||
|
||||
""" Création d'une absence et utilisation de AnnuleAbsenceDatesNoJust """
|
||||
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_views
|
||||
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- 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",
|
||||
)
|
||||
|
||||
# --- Création d'un étudiant
|
||||
etud = G.create_etud(code_nip=None)
|
||||
G.inscrit_etudiant(sem, etud)
|
||||
etudid=etud["etudid"]
|
||||
|
||||
# --- Création d'une absence
|
||||
sco_abs_views.doSignaleAbsence(context.Absences, datedebut="22/01/2021", datefin="22/01/2021", demijournee=2, etudid=etudid, REQUEST=REQUEST)
|
||||
|
||||
# --- Annulation d'absence
|
||||
context.Absences.AnnuleAbsencesDatesNoJust(etudid, dates="22/01/2021", REQUEST=REQUEST)
|
||||
|
||||
""" Erreur : File "/opt/scodoc/Products/ScoDoc/ZAbsences.py", line 323, in AnnuleAbsencesDatesNoJust
|
||||
vars(),
|
||||
psycopg2.DataError: invalid input syntax for type date: "2"
|
||||
LINE 1: ...es where etudid='EID1' and (not estjust) and jour='2' and mo... """
|
108
scotests/test_CountAbs.py
Executable file
108
scotests/test_CountAbs.py
Executable file
@ -0,0 +1,108 @@
|
||||
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 CountAbs() de sco_abs
|
||||
|
||||
a = sco_abs.getAbsSemEtud(context.Absences, sem, etudid)
|
||||
nb_abs = a.CountAbs()
|
||||
nb_absj = a.CountAbsJust()
|
||||
|
||||
# --- 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 nb_abs == nb_abs2 == 5
|
||||
assert nb_absj == nb_absj2 == 4
|
||||
|
||||
# --- Supression d'absence
|
||||
|
||||
_ = sco_abs_views.doAnnuleAbsence(context.Absences, "19/01/2021", "19/01/2021", 2, etudid=etudid, REQUEST=REQUEST)
|
||||
b = sco_abs.getAbsSemEtud(context.Absences, sem, etudid)
|
||||
|
||||
# --- Vérification
|
||||
|
||||
new_nbabs = b.CountAbs()
|
||||
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.
|
||||
"""
|
267
scotests/test_absence2.py
Executable file
267
scotests/test_absence2.py
Executable file
@ -0,0 +1,267 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -
|
||||
|
||||
""""
|
||||
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 de listes d'absences, création de billet
|
||||
et creation d'un groupe.
|
||||
|
||||
Fonction de l'API utilisé :
|
||||
- doSignaleAbsence
|
||||
- doJustifAbsence
|
||||
- AddBilletAbs
|
||||
- XMLgetBilletAbsence
|
||||
- listeBilletEtud
|
||||
- ListeAbsJust
|
||||
- CountAbsJust
|
||||
- ListAbsNonJust
|
||||
- ListJustifs
|
||||
- ListeAbsJour
|
||||
- ListAbsInRange
|
||||
|
||||
Fonction renvoyant du code HTML :
|
||||
- EtatAbsences
|
||||
- SignaleAbsenceGrSemestre
|
||||
- SignaleAbsenceGrHebdo
|
||||
- EtatAbsenceDate
|
||||
- AddBilletAbsenceForm
|
||||
- AnnuleAbsenceEtud
|
||||
- ProcessBilletAbsenceForm
|
||||
- JustifAbsenceEtud
|
||||
- doAnnuleJustif
|
||||
|
||||
"""
|
||||
|
||||
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)
|
||||
|
||||
# --- Création d'un groupe
|
||||
|
||||
_ = sco_groups.partition_create(context.Scolarite, formsemestre_id=sem["formsemestre_id"], partition_name="Eleve", REQUEST=REQUEST)
|
||||
li1 = sco_groups.get_partitions_list(context.Scolarite, sem["formsemestre_id"])
|
||||
_ = sco_groups.createGroup(context.Scolarite, li1[0]["partition_id"], "Groupe 1", REQUEST=REQUEST)
|
||||
|
||||
# --- Affectation des élèves dans des groupes
|
||||
|
||||
li_grp1 = sco_groups.get_partition_groups(context.Scolarite, li1[0])
|
||||
for etud in etuds :
|
||||
sco_groups.set_group(context.Scolarite, etud["etudid"], li_grp1[0]["group_id"])
|
||||
|
||||
# --- Saisie absences
|
||||
etudid = etuds[0]["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)
|
||||
|
||||
_ = sco_abs_views.doSignaleAbsence(
|
||||
context.Absences,
|
||||
"22/01/2021",
|
||||
"22/01/2021",
|
||||
demijournee=1,
|
||||
etudid=etuds[1]["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)
|
||||
|
||||
# --- Test
|
||||
|
||||
_ = context.Absences.doSignaleAbsenceGrSemestre(
|
||||
dates="2021-01-13,2021-01-25",
|
||||
etudids= etuds[5]["etudid"]+","+etuds[6]["etudid"],
|
||||
destination="",
|
||||
REQUEST=REQUEST
|
||||
) # <----- rien ne se passe (pb parametre ?)
|
||||
|
||||
# --- Création de billets
|
||||
|
||||
b1 = context.Absences.AddBilletAbsence(
|
||||
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,
|
||||
)
|
||||
|
||||
b2 = context.Absences.AddBilletAbsence(
|
||||
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,
|
||||
)
|
||||
|
||||
# --- XMLgetBilletEtud
|
||||
|
||||
xml_bi = context.Absences.XMLgetBilletsEtud(etudid=etudid, REQUEST=REQUEST)
|
||||
print(1)
|
||||
print(xml_bi)
|
||||
print(1)
|
||||
|
||||
# --- Supression de billet
|
||||
li_bi = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||||
load_li_bi = json.loads(li_bi)
|
||||
|
||||
#_ = context.Absences.deleteBilletAbsence(load_li_bi[1]["billet_id"], REQUEST=REQUEST)
|
||||
|
||||
li_bi2 = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||||
load_li_bi2 = json.loads(li_bi)
|
||||
|
||||
#assert len(load_li_bi2) == 1
|
||||
#assert load_li_bi2[0]["description"] == "abs du 22"
|
||||
|
||||
# --- Créaton de listes
|
||||
|
||||
li_abs_just = context.Absences.ListeAbsJust(etudid = etudid, datedebut="01/01/2021")
|
||||
nb_abs_just = context.Absences.CountAbsJust(etudid, debut="01/01/2021", fin="06/30/2021")
|
||||
assert len(li_abs_just) == nb_abs_just
|
||||
assert li_abs_just[0]["etudid"] == etudid
|
||||
assert li_abs_just[0]["matin"] == True
|
||||
assert li_abs_just[0]["jour"] == datetime.date(2021, 1, 15)
|
||||
assert li_abs_just[2]["jour"] == datetime.date(2021, 1, 19)
|
||||
assert li_abs_just[2]["matin"] == False
|
||||
|
||||
|
||||
li_abs_njust = context.Absences.ListeAbsNonJust(etudid=etudid, datedebut="01/01/2021")
|
||||
nb_abs = context.Absences.CountAbs(etudid, debut="01/01/2021", fin="06/30/2021")
|
||||
assert len(li_abs_njust) == nb_abs - nb_abs_just
|
||||
assert li_abs_njust[0]["matin"] == True
|
||||
assert li_abs_njust[0]["etudid"] == etudid
|
||||
assert li_abs_njust[0]["jour"] == datetime.date(2021, 1, 22)
|
||||
|
||||
|
||||
li_just = context.Absences.ListeJustifs(etudid=etudid, datedebut="01/01/2021")
|
||||
assert len(li_just) == 4
|
||||
li_just2 = context.Absences.ListeJustifs(etudid=etudid, datedebut="01/01/2021", datefin="01/18/2021")
|
||||
assert len(li_just2) == 2
|
||||
|
||||
|
||||
li_jour = context.Absences.ListeAbsJour(date="01/22/2021")
|
||||
assert len(li_jour) == 2
|
||||
li_jour2 = context.Absences.ListeAbsJour(date="01/18/2021")
|
||||
assert len(li_jour2) == 1
|
||||
|
||||
|
||||
li_range = context.Absences.ListAbsInRange(etudid, debut="01/01/2021", fin="06/01/2021")
|
||||
assert len(li_range) == 5
|
||||
|
||||
#li_xml = context.Absences.XMLgetAbsEtud(beg_date="01/01/2021", end_date="01/06/2021", REQUEST=REQUEST)
|
||||
#print(li_xml) need etudid
|
||||
|
||||
# --- Annulation d'absence
|
||||
|
||||
#context.Absences.AnnuleAbsencesDatesNoJust(etudid, dates="22/01/2021", REQUEST=REQUEST)
|
||||
|
||||
|
||||
# --- Fonction renvoyant du code HTML
|
||||
|
||||
etat_abs = context.Absences.EtatAbsences(REQUEST=REQUEST)
|
||||
|
||||
#cal_abs = sco_abs_views.CalAbs(context.Absences, REQUEST=REQUEST) #<--- retourne html + need etudid : how?
|
||||
|
||||
sag = context.Absences.SignaleAbsenceGrSemestre(
|
||||
datedebut="15/01/2021",
|
||||
datefin="22/01/2021",
|
||||
group_ids=[li_grp1[0]["group_id"]],
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
sagh = context.Absences.SignaleAbsenceGrHebdo(
|
||||
datelundi="18/01/2021", group_ids=[li_grp1[0]["group_id"]], destination="", REQUEST=REQUEST
|
||||
)
|
||||
|
||||
grp_abs_d = context.Absences.EtatAbsencesDate(group_ids=[li_grp1[0]["group_id"]], date="22/01/2021", REQUEST=REQUEST)
|
||||
|
||||
billet_form = context.Absences.AddBilletAbsenceForm(etudid=etudid, REQUEST=REQUEST)
|
||||
|
||||
#an_abs = AnnuleAbsenceEtud(context.Absences, REQUEST=REQUEST) #<- retourne html + need etudid : how?
|
||||
|
||||
#proc = context.Absences.ProcessBilletAbsenceForm(billet_id=load_li_bi[0]["billet_id"], REQUEST=REQUEST) #error
|
||||
|
||||
#just_form = sco_abs_views.JustifAbsenceEtud(context.Absences, REQUEST=REQUEST)
|
||||
|
||||
#delete_just = sco_abs_views.doAnnuleJustif(context.Absences, datedebut0="22/01/2021", datefin0="22/01/2021", demijournee=2, REQUEST=REQUEST)
|
||||
|
||||
|
||||
"""
|
||||
Commentaire :
|
||||
|
||||
Certaines fonctions ont besoin de l'id de l'étudiant mais n'ont pas ce parametre comment le récupérer ?
|
||||
(CalAbs, SignaleAbsenceEtud, AnnuleAbsenceEtud, JustifAbsenceEtud, doAnnuleJustif, XMLgetAbsEtud)
|
||||
|
||||
D'autres fonctions renvoient du HTML -> comment les tester en python?
|
||||
|
||||
doSignaleAbsenceGrSemestre -> ne fonctionne pas (pb au niveau de l'écriture des parametres au lancement
|
||||
de la fonction?)
|
||||
|
||||
XMLgetBilletsEtud, deleteBilletAbsence -> fonction get ne retourne rien et delete ne supprime rien
|
||||
(lancer fichier test_billet)
|
||||
|
||||
AnnuleAbsencesDatesNoJust -> error line 323, jour='2' (2 doit être un int et non un string?)
|
||||
|
||||
"""
|
||||
|
||||
|
261
scotests/test_api7doc.py
Executable file
261
scotests/test_api7doc.py
Executable file
@ -0,0 +1,261 @@
|
||||
import sco_formations
|
||||
import json
|
||||
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_moduleimpl
|
||||
import sco_groups_view
|
||||
import sco_abs_views
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
file = open("scotests/export_formation1.xml")
|
||||
doc = file.read()
|
||||
file.close()
|
||||
|
||||
# --- Création de la formation
|
||||
|
||||
f = sco_formations.formation_import_xml(REQUEST=REQUEST, doc=doc, context=context.Notes)
|
||||
|
||||
# --- Création des semestres
|
||||
|
||||
sem1 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=1,
|
||||
date_debut="01/09/2020",
|
||||
date_fin="01/02/2021",
|
||||
)
|
||||
|
||||
sem3 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=3,
|
||||
date_debut="01/09/2020",
|
||||
date_fin="01/02/2021",
|
||||
)
|
||||
|
||||
sem2 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=2,
|
||||
date_debut="02/02/2021",
|
||||
date_fin="01/06/2021",
|
||||
)
|
||||
|
||||
sem4 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=4,
|
||||
date_debut="02/02/2021",
|
||||
date_fin="01/06/2021",
|
||||
)
|
||||
|
||||
|
||||
# --- Implémentation des modules
|
||||
|
||||
li_module = context.Notes.do_module_list()
|
||||
mods_imp = []
|
||||
for mod in li_module :
|
||||
if mod["semestre_id"] == 1 :
|
||||
formsemestre_id = sem1["formsemestre_id"]
|
||||
elif mod["semestre_id"] == 2 :
|
||||
formsemestre_id = sem2["formsemestre_id"]
|
||||
elif mod["semestre_id"] == 3 :
|
||||
formsemestre_id = sem3["formsemestre_id"]
|
||||
else :
|
||||
formsemestre_id = sem4["formsemestre_id"]
|
||||
|
||||
mi = G.create_moduleimpl(
|
||||
module_id=mod["module_id"],
|
||||
formsemestre_id=formsemestre_id,
|
||||
responsable_id="bach",
|
||||
)
|
||||
mods_imp.append(mi)
|
||||
|
||||
# --- Création des étudiants
|
||||
|
||||
etuds=[]
|
||||
for nom, prenom in [
|
||||
("Semestre11", "EtudiantNumero1"),
|
||||
("Semestre12", "EtudiantNumero2"),
|
||||
("Semestre23", "EtudiantNumero3"),
|
||||
("Semestre24", "EtudiantNumero4"),
|
||||
("Semestre35", "EtudiantNumero5"),
|
||||
("Semestre36", "EtudiantNumero6"),
|
||||
("Semestre47", "EtudiantNumero7"),
|
||||
("Semestre48", "EtudiantNumero8")
|
||||
] :
|
||||
etud = G.create_etud(
|
||||
nom=nom,
|
||||
prenom=prenom,
|
||||
)
|
||||
etuds.append(etud)
|
||||
|
||||
# --- Inscription des étudiants
|
||||
|
||||
for etud in etuds[0:2]:
|
||||
G.inscrit_etudiant(sem1, etud)
|
||||
|
||||
for etud in etuds[2:4]:
|
||||
G.inscrit_etudiant(sem2, etud)
|
||||
|
||||
for etud in etuds[4:6]:
|
||||
G.inscrit_etudiant(sem3, etud)
|
||||
|
||||
for etud in etuds[6:]:
|
||||
G.inscrit_etudiant(sem4, etud)
|
||||
|
||||
# --- Création d'une évaluation pour chaque UE
|
||||
|
||||
lim_sem1 = sco_moduleimpl.do_moduleimpl_list(context.Notes, formsemestre_id=sem1["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_lim_sem1 = json.loads(lim_sem1)
|
||||
|
||||
lim_sem2 = sco_moduleimpl.do_moduleimpl_list(context.Notes, formsemestre_id=sem2["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_lim_sem2 = json.loads(lim_sem2)
|
||||
|
||||
lim_sem3 = sco_moduleimpl.do_moduleimpl_list(context.Notes, formsemestre_id=sem3["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_lim_sem3 = json.loads(lim_sem3)
|
||||
|
||||
lim_sem4 = sco_moduleimpl.do_moduleimpl_list(context.Notes, formsemestre_id=sem4["formsemestre_id"], REQUEST=REQUEST)
|
||||
load_lim_sem4 = json.loads(lim_sem4)
|
||||
|
||||
|
||||
for moduleimpl_id, jour, description, coefficient in [
|
||||
(load_lim_sem1[1]["moduleimpl_id"], "02/09/2020", "InterroTestSemestre1", 1.0),
|
||||
(load_lim_sem1[2]["moduleimpl_id"], "03/09/2020", "InterroTestSemestre1", 1.0),
|
||||
(load_lim_sem2[1]["moduleimpl_id"], "03/02/2021", "InterroTestSemestre2", 1.0),
|
||||
(load_lim_sem2[8]["moduleimpl_id"], "04/02/2021", "InterroTestSemestre2", 1.0),
|
||||
(load_lim_sem3[3]["moduleimpl_id"], "02/09/2020", "InterroTestSemestre3", 1.0),
|
||||
(load_lim_sem3[9]["moduleimpl_id"], "03/09/2020", "InterroTestSemestre3", 1.0),
|
||||
(load_lim_sem3[15]["moduleimpl_id"], "04/09/2020", "InterroTestSemestre3", 1.0),
|
||||
(load_lim_sem4[3]["moduleimpl_id"], "03/02/2021", "InterroTestSemestre4", 1.0),
|
||||
(load_lim_sem4[9]["moduleimpl_id"], "04/02/2021", "InterroTestSemestre4", 1.0),
|
||||
(load_lim_sem4[13]["moduleimpl_id"], "05/02/2021", "InterroTestSemestre4", 1.0),
|
||||
] :
|
||||
e = G.create_evaluation(moduleimpl_id=moduleimpl_id, jour=jour, description=description, coefficient=coefficient)
|
||||
|
||||
|
||||
# --- Saisie des notes des étudiants (un élève a 12, un autre a 7 pour chaque semestre)
|
||||
|
||||
lie1 = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem1["formsemestre_id"])
|
||||
lie2 = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem2["formsemestre_id"])
|
||||
lie3 = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem3["formsemestre_id"])
|
||||
lie4 = context.Notes.do_evaluation_list_in_formsemestre(formsemestre_id=sem4["formsemestre_id"])
|
||||
|
||||
for eval in lie1 :
|
||||
for etud in etuds[:2] :
|
||||
if etud == etuds[0] :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=12.0)
|
||||
else :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=7.0)
|
||||
|
||||
for eval in lie2 :
|
||||
for etud in etuds[2:4] :
|
||||
if etud == etuds[2] :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=12.0)
|
||||
else :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=7.0)
|
||||
|
||||
|
||||
for eval in lie3 :
|
||||
for etud in etuds[4:6] :
|
||||
if etud == etuds[4] :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=12.0)
|
||||
else :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=7.0)
|
||||
|
||||
for eval in lie4 :
|
||||
for etud in etuds[6:] :
|
||||
if etud == etuds[6] :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=12.0)
|
||||
else :
|
||||
nb_changed, nb_suppress, existing_decisions = G.create_note(evaluation=eval, etud=etud, note=7.0)
|
||||
|
||||
# --- Département
|
||||
|
||||
li_dep = context.ScoDoc.list_depts(format="json", REQUEST=REQUEST)
|
||||
print(li_dep)
|
||||
|
||||
# --- Formation
|
||||
|
||||
lif = context.Notes.formation_list(format="json", REQUEST=REQUEST, formation_id=f[0])
|
||||
load_lif = json.loads(lif)
|
||||
assert len(load_lif) == 1
|
||||
assert load_lif[0]["formation_id"] == f[0]
|
||||
|
||||
exp = sco_formations.formation_export(context.Notes, formation_id=f[0], format="json", REQUEST=REQUEST)
|
||||
load_exp = json.loads(exp)
|
||||
assert load_exp["acronyme"] == "DUT Info"
|
||||
assert load_exp["titre_officiel"] == "DUT Informatique"
|
||||
assert load_exp["formation_code"] == "FCOD2"
|
||||
|
||||
# --- Semestre
|
||||
|
||||
li_sem = context.Notes.formsemestre_list(formation_id=f[0], format = "json", REQUEST=REQUEST)
|
||||
load_li_sem = json.loads(li_sem)
|
||||
assert len(load_li_sem) == 4
|
||||
|
||||
# --- Création des groupes
|
||||
|
||||
_ = sco_groups.partition_create(context.Scolarite, formsemestre_id=sem1["formsemestre_id"], partition_name="Eleve 1ere annee", REQUEST=REQUEST)
|
||||
|
||||
li1 = sco_groups.get_partitions_list(context.Scolarite, sem1["formsemestre_id"])
|
||||
|
||||
_ = sco_groups.createGroup(context.Scolarite, li1[0]["partition_id"], "Groupe S1A", REQUEST=REQUEST)
|
||||
|
||||
li_grp1 = sco_groups.get_partition_groups(context.Scolarite, li1[0])
|
||||
|
||||
for etud in etuds[0:2] :
|
||||
sco_groups.set_group(context.Scolarite, etud["etudid"], li_grp1[0]["group_id"])
|
||||
|
||||
|
||||
# --- Groupes
|
||||
|
||||
li_part = sco_groups.formsemestre_partition_list(context.Scolarite, formsemestre_id=sem1["formsemestre_id"], format = "json", REQUEST=REQUEST)
|
||||
load_li_part = json.loads(li_part)
|
||||
assert len(load_li_part) == 2 # 2 partition (defaut et eleve 1ere annee)
|
||||
assert load_li_part[0]["formsemestre_id"] == sem1["formsemestre_id"]
|
||||
assert len(load_li_part[0]["group"]) == 1 # 2 groupes S1A
|
||||
assert load_li_part[0]["group"][0]["group_name"] == "Groupe S1A"
|
||||
assert load_li_part[0]["group"][0]["group_id"] == li_grp1[0]["group_id"]
|
||||
assert load_li_part[0]["partition_id"] == load_li_part[0]["group"][0]["partition_id"] == li1[0]["partition_id"]
|
||||
assert load_li_part[0]["partition_name"] == "Eleve 1ere annee"
|
||||
|
||||
vue_g1 = sco_groups_view.groups_view(context.Scolarite, group_ids = [li_grp1[0]["group_id"]], format = "json", REQUEST=REQUEST)
|
||||
load_vue_g1 = json.loads(vue_g1)
|
||||
assert len(load_vue_g1) == 2
|
||||
assert load_vue_g1[0][li1[0]["partition_id"]] == li_grp1[0]["group_name"]
|
||||
|
||||
|
||||
# --- Etudiant
|
||||
|
||||
etudi = context.Scolarite.etud_info(etudid=etuds[0]["etudid"], format="json", REQUEST=REQUEST)
|
||||
load_etudi = json.loads(etudi)
|
||||
assert load_etudi["prenom"] == "Etudiantnumero1"
|
||||
assert load_etudi["nom"] == "SEMESTRE11"
|
||||
assert load_etudi["etudid"] == etuds[0]["etudid"]
|
||||
|
||||
# --- Absences
|
||||
|
||||
for debut, fin, demijournee in [
|
||||
("18/01/2021", "18/01/2021", 1),
|
||||
("19/01/2021", "19/01/2021", 0),
|
||||
] :
|
||||
sco_abs_views.doSignaleAbsence(context.Absences, datedebut=debut, datefin=fin, demijournee=demijournee, etudid=etuds[0]["etudid"], REQUEST=REQUEST)
|
||||
|
||||
nb_abs = context.Absences.CountAbs(etuds[0]["etudid"], debut="09/01/2020", fin="02/01/2021")
|
||||
assert nb_abs == 2
|
||||
|
||||
liste_abs = sco_abs_views.ListeAbsEtud(context.Absences, etuds[0]["etudid"], format='json', REQUEST=REQUEST)
|
||||
load_liste_abs = json.loads(liste_abs)
|
||||
assert len(load_liste_abs) == 2
|
||||
|
||||
_ = sco_abs_views.doAnnuleAbsence(context.Absences, "15/01/2021", "15/01/2021", 1, etudid=etuds[0]["etudid"], REQUEST=REQUEST)
|
||||
|
||||
# --- Module
|
||||
|
||||
#Voir test dans test_formation.
|
||||
|
||||
|
||||
|
96
scotests/test_billet.py
Executable file
96
scotests/test_billet.py
Executable file
@ -0,0 +1,96 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -
|
||||
|
||||
""" Création de billet, utilisation de XMLgetBilletsEtud et suppression de billet """
|
||||
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_views
|
||||
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- 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",
|
||||
)
|
||||
|
||||
# --- Création d'un étudiant
|
||||
etud = G.create_etud(code_nip=None)
|
||||
G.inscrit_etudiant(sem, etud)
|
||||
etudid=etud["etudid"]
|
||||
|
||||
# --- Création d'une absence
|
||||
sco_abs_views.doSignaleAbsence(context.Absences, datedebut="22/01/2021", datefin="22/01/2021", demijournee=2, etudid=etudid, REQUEST=REQUEST)
|
||||
|
||||
# --- Création d'un billet
|
||||
b1 = context.Absences.AddBilletAbsence(
|
||||
begin="2021-01-22 00:00",
|
||||
end="2021-01-22 23:59",
|
||||
etudid=etudid,
|
||||
description = "abs du 22",
|
||||
justified=False,
|
||||
code_nip=etud["code_nip"],
|
||||
code_ine=etud["code_ine"],
|
||||
REQUEST=REQUEST,
|
||||
)
|
||||
|
||||
# --- XMLgetBilletEtud
|
||||
|
||||
xml_bi = context.Absences.XMLgetBilletsEtud(etudid=etudid, REQUEST=REQUEST)
|
||||
print(1)
|
||||
print(xml_bi)
|
||||
print(1)
|
||||
|
||||
|
||||
# --- Suppression d'un billet
|
||||
li_bi = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||||
load_li_bi = json.loads(li_bi)
|
||||
|
||||
_ = context.Absences.deleteBilletAbsence(load_li_bi[0]["billet_id"], REQUEST=REQUEST)
|
||||
|
||||
li_bi2 = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||||
load_li_bi2 = json.loads(li_bi)
|
||||
|
||||
assert len(load_li_bi2) == 0
|
||||
|
||||
"""
|
||||
Commentaire :
|
||||
|
||||
XMLgetBilletsEtud retourne une chaine vide
|
||||
|
||||
deleteBilletsEtud : erreur
|
||||
File "/opt/scodoc/Products/ScoDoc/ZAbsences.py", line 1809, in deleteBilletAbsence
|
||||
parameters={"billet_id": billet_id},
|
||||
File "/opt/scodoc/Products/ScoDoc/ZScolar.py", line 2664, in confirmDialog
|
||||
return self.sco_header(REQUEST) + "\n".join(H) + self.sco_footer(REQUEST)
|
||||
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 223: ordinal not in range(128)
|
||||
|
||||
"""
|
69
scotests/test_deleteBilletAbsence.py
Executable file
69
scotests/test_deleteBilletAbsence.py
Executable file
@ -0,0 +1,69 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -
|
||||
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_views
|
||||
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- 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",
|
||||
)
|
||||
|
||||
# --- Création d'un étudiant
|
||||
etud = G.create_etud(code_nip=None)
|
||||
G.inscrit_etudiant(sem, etud)
|
||||
etudid=etud["etudid"]
|
||||
|
||||
# --- Création d'une absence
|
||||
sco_abs_views.doSignaleAbsence(context.Absences, datedebut="22/01/2021", datefin="22/01/2021", demijournee=2, etudid=etudid, REQUEST=REQUEST)
|
||||
|
||||
# --- Création d'un billet
|
||||
b1 = context.Absences.AddBilletAbsence(
|
||||
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,
|
||||
)
|
||||
|
||||
# --- Suppression d'un billet
|
||||
_ = context.Absences.deleteBilletAbsence(load_li_bi[1]["billet_id"], REQUEST=REQUEST)
|
||||
|
||||
li_bi = context.Absences.listeBilletsEtud(etudid=etudid, REQUEST=REQUEST, format="json")
|
||||
load_li_bi = json.loads(li_bi)
|
||||
|
||||
assert len(load_li_bi) == 0
|
46
scotests/test_edit.py
Executable file
46
scotests/test_edit.py
Executable file
@ -0,0 +1,46 @@
|
||||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -
|
||||
|
||||
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
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- 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",
|
||||
)
|
||||
|
||||
# --- Modification d'un module
|
||||
|
||||
context.Notes.do_module_edit({"module_id":mod["module_id"], "code": "MOD1", "titre" : "module modifie"})
|
||||
print(mod)
|
||||
|
135
scotests/test_etudiant.py
Executable file
135
scotests/test_etudiant.py
Executable file
@ -0,0 +1,135 @@
|
||||
""" Création de 2 étudiants, un qui demissionne, un autre defaillant + annuler demission et annuler défaillance
|
||||
|
||||
Fonctions de l’API utilisé :
|
||||
- doDemEtudiant
|
||||
- doDefEtudiant
|
||||
- doCancelDem
|
||||
- doCancelDef
|
||||
- etud_info
|
||||
- search_etud_in_dept
|
||||
- fillEtudsInfo
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import random
|
||||
|
||||
# La variable context est définie par le script de lancement
|
||||
# l'affecte ainsi pour éviter 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 scolars
|
||||
import sco_find_etud
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
# --- Création d'étudiants
|
||||
|
||||
etud1 = G.create_etud(
|
||||
code_nip="",
|
||||
nom="Poire",
|
||||
prenom="Kevin",
|
||||
code_ine="",
|
||||
civilite="M",
|
||||
etape="TST1",
|
||||
email="test1@localhost",
|
||||
emailperso="perso1@localhost",
|
||||
date_naissance="01/05/2001",
|
||||
lieu_naissance="Stains",
|
||||
dept_naissance="93",
|
||||
domicile="11, rue du test",
|
||||
codepostaldomicile="93430",
|
||||
villedomicile="Villetaneuse",
|
||||
paysdomicile="France",
|
||||
telephone="0102030405",
|
||||
typeadresse="domicile",
|
||||
boursier=None,
|
||||
description="etudiant test",
|
||||
)
|
||||
|
||||
etud2 = G.create_etud()
|
||||
|
||||
# --- 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/2020",
|
||||
date_fin="30/06/2020",
|
||||
)
|
||||
|
||||
mi = G.create_moduleimpl(
|
||||
module_id=mod["module_id"],
|
||||
formsemestre_id=sem["formsemestre_id"],
|
||||
responsable_id="bach",
|
||||
)
|
||||
|
||||
# --- Inscription des étudiants
|
||||
|
||||
G.inscrit_etudiant(sem, etud1)
|
||||
G.inscrit_etudiant(sem, etud2)
|
||||
|
||||
# --- Etud_info
|
||||
|
||||
info = context.Scolarite.etud_info(etud1["etudid"], format = "json", REQUEST=REQUEST)
|
||||
load_info = json.loads(info)
|
||||
|
||||
|
||||
# --- Démission étudiant
|
||||
|
||||
context.doDemEtudiant(etud1["etudid"], sem["formsemestre_id"], event_date="01/01/2021")
|
||||
|
||||
bul = sco_bulletins.formsemestre_bulletinetud_dict(context.Notes, sem["formsemestre_id"], etud1["etudid"])
|
||||
assert bul["moy_gen"] == "NA"
|
||||
assert bul["ins"][0]["etat"] == "D"
|
||||
|
||||
# --- Défaillance d'un étudiant
|
||||
|
||||
context.doDefEtudiant(etud2["etudid"], sem["formsemestre_id"], event_date="01/01/2021")
|
||||
|
||||
bul = sco_bulletins.formsemestre_bulletinetud_dict(context.Notes, sem["formsemestre_id"], etud1["etudid"])
|
||||
assert bul["moy_gen"] == "NA"
|
||||
assert bul["ins"][0]["etat"] == "D"
|
||||
|
||||
# --- Annuler démission
|
||||
|
||||
context.Scolarite.doCancelDem(etud1["etudid"], sem["formsemestre_id"], REQUEST=REQUEST)
|
||||
bul = sco_bulletins.formsemestre_bulletinetud_dict(context.Notes, sem["formsemestre_id"], etud1["etudid"])
|
||||
print(bul["ins"][0]["etat"])
|
||||
#assert bul["ins"][0]["etat"] == "I"
|
||||
|
||||
# --- Annuler défaillance
|
||||
|
||||
context.Scolarite.doCancelDef(etud2["etudid"], sem["formsemestre_id"], REQUEST=REQUEST)
|
||||
bul = sco_bulletins.formsemestre_bulletinetud_dict(context.Notes, sem["formsemestre_id"], etud1["etudid"])
|
||||
print(bul["ins"][0]["etat"])
|
||||
#assert bul["ins"][0]["etat"] == "I"
|
||||
|
||||
# --- Fonctions retournant HTML
|
||||
|
||||
find = sco_find_etud.search_etud_in_dept(context.Scolarite, expnom="Poire", REQUEST=REQUEST)
|
||||
|
||||
_ = context.Scolarite.fillEtudsInfo(etuds=[etud1])
|
||||
|
||||
"""
|
||||
Commentaire :
|
||||
|
||||
L'etat ne se met pas à jour après l'annulation de la démission ou de la défaillance.
|
||||
|
||||
etud_info ne donne pas toutes les infos de l'étudiant voir mini test create_etud.
|
||||
|
||||
"""
|
79
scotests/test_formation_export_xml.py
Executable file
79
scotests/test_formation_export_xml.py
Executable file
@ -0,0 +1,79 @@
|
||||
import sco_formations
|
||||
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_moduleimpl
|
||||
|
||||
G = sco_fake_gen.ScoFake(context.Notes)
|
||||
G.verbose = False
|
||||
|
||||
file = open("scotests/export_formation1.xml")
|
||||
doc = file.read()
|
||||
file.close()
|
||||
|
||||
print(doc)
|
||||
print("\n \n \n")
|
||||
# --- Création de la formation
|
||||
|
||||
f = sco_formations.formation_import_xml(REQUEST=REQUEST, doc=doc, context=context.Notes)
|
||||
|
||||
|
||||
# --- Création des semestres
|
||||
|
||||
sem1 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=1,
|
||||
date_debut="01/09/2020",
|
||||
date_fin="01/02/2021",
|
||||
)
|
||||
|
||||
sem3 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=3,
|
||||
date_debut="01/09/2020",
|
||||
date_fin="01/02/2021",
|
||||
)
|
||||
|
||||
sem2 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=2,
|
||||
date_debut="02/02/2021",
|
||||
date_fin="01/06/2021",
|
||||
)
|
||||
|
||||
sem4 = G.create_formsemestre(
|
||||
formation_id=f[0],
|
||||
semestre_id=4,
|
||||
date_debut="02/02/2021",
|
||||
date_fin="01/06/2021",
|
||||
)
|
||||
|
||||
|
||||
# --- Implémentation des modules
|
||||
|
||||
li_module = context.Notes.do_module_list()
|
||||
mods_imp = []
|
||||
for mod in li_module :
|
||||
if mod["semestre_id"] == 1 :
|
||||
formsemestre_id = sem1["formsemestre_id"]
|
||||
elif mod["semestre_id"] == 2 :
|
||||
formsemestre_id = sem2["formsemestre_id"]
|
||||
elif mod["semestre_id"] == 3 :
|
||||
formsemestre_id = sem3["formsemestre_id"]
|
||||
else :
|
||||
formsemestre_id = sem4["formsemestre_id"]
|
||||
|
||||
mi = G.create_moduleimpl(
|
||||
module_id=mod["module_id"],
|
||||
formsemestre_id=formsemestre_id,
|
||||
responsable_id="bach",
|
||||
)
|
||||
mods_imp.append(mi)
|
||||
|
||||
# --- Test de export_formation format xml
|
||||
|
||||
form_exp = context.Notes.formation_export(formation_id=f[0], format="xml", REQUEST=REQUEST)
|
||||
print(form_exp[39:])
|
Loading…
Reference in New Issue
Block a user