ScoDoc/scotests/test_scenario1_formation.py

72 lines
1.8 KiB
Python

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)