1
0
forked from ScoDoc/ScoDoc
ScoDoc/scotests/test_scenario2_formation.py

105 lines
2.6 KiB
Python
Raw Normal View History

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