MonScoDocEssai/scotests/test_scenario2_formation.py

106 lines
2.5 KiB
Python
Raw Normal View History

import sco_formations
import random
2021-08-01 10:16:16 +02:00
# 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
2021-08-20 01:09:55 +02:00
f = sco_formations.formation_import_xml(doc=doc)
2021-08-01 10:16:16 +02:00
# --- 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 = []
2021-08-01 10:16:16 +02:00
for mod in li_module:
if mod["semestre_id"] == 1:
formsemestre_id = sem1["formsemestre_id"]
2021-08-01 10:16:16 +02:00
elif mod["semestre_id"] == 2:
formsemestre_id = sem2["formsemestre_id"]
2021-08-01 10:16:16 +02:00
elif mod["semestre_id"] == 3:
formsemestre_id = sem3["formsemestre_id"]
2021-08-01 10:16:16 +02:00
else:
formsemestre_id = sem4["formsemestre_id"]
mi = G.create_moduleimpl(
2021-08-01 10:16:16 +02:00
module_id=mod["module_id"],
formsemestre_id=formsemestre_id,
responsable_id="bach",
)
mods_imp.append(mi)
# --- Création des étudiants
2021-08-01 10:16:16 +02:00
etuds = []
for nom, prenom in [
("Semestre11", "EtudiantNumero1"),
("Semestre12", "EtudiantNumero2"),
("Semestre23", "EtudiantNumero3"),
("Semestre24", "EtudiantNumero4"),
("Semestre35", "EtudiantNumero5"),
("Semestre36", "EtudiantNumero6"),
("Semestre47", "EtudiantNumero7"),
2021-08-01 10:16:16 +02:00
("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)