ScoDoc-Lille/scotests/test_formation_export_xml.py

83 lines
2.0 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()
print(doc)
print("\n \n \n")
# --- 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)
# --- Test de export_formation format xml
2021-08-20 01:09:55 +02:00
form_exp = sco_formations.formation_export(
2021-08-01 10:16:16 +02:00
formation_id=f[0], format="xml", REQUEST=REQUEST
)
print(form_exp[39:])