2021-07-31 18:01:10 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
""" Test creation/edition/import/export formations
|
|
|
|
"""
|
|
|
|
|
|
|
|
# test écrit par Fares Amer, mai 2021 et porté sur ScoDoc 8 en juillet 2021
|
|
|
|
|
|
|
|
# Créer 2 formations, une test et une normale. Créer 2 semestres dans la formation normale et un
|
|
|
|
# dans la formation test, créer 2 semestres dans la formation normale (un test et un normal),
|
|
|
|
# 2 ue (un test et un normal), 2 modules (un test et un normal) et 2 matieres (test et normal).
|
|
|
|
# Et dans la formations test, un semestre, un module, un ue et une matiere.
|
|
|
|
# Afficher la liste de tout ca puis supprimer les ue, mod, mat et sem test ainsi
|
|
|
|
# que la formation test. Afficher la liste des UE, formations et modules restante.
|
|
|
|
#
|
|
|
|
# Vérification :
|
|
|
|
#
|
|
|
|
# - Les listes initiales comprennent bien tout les éléments créés avec les bon noms etc
|
|
|
|
# - La supression s'est bien effectué au niveau de scodoc web et en python
|
|
|
|
# - Vérifier que les fonctions listes font bien la mise à jour après supression
|
|
|
|
#
|
|
|
|
# Fonction de l'API utilisé :
|
|
|
|
#
|
|
|
|
# - create_formation
|
|
|
|
# - create_ue
|
|
|
|
# - create_matiere
|
|
|
|
# - create_module
|
|
|
|
# - create_formsemestre
|
|
|
|
# - create_moduleimpl
|
|
|
|
# - formation_list
|
|
|
|
# - formation_export
|
|
|
|
# - formsemestre_list
|
2021-10-15 14:00:51 +02:00
|
|
|
# - moduleimpl_list
|
2021-07-31 18:01:10 +02:00
|
|
|
# - do_module_impl_with_module_list
|
|
|
|
# - do_formsemestre_delete
|
2021-10-16 19:20:36 +02:00
|
|
|
# - module_list
|
2021-07-31 18:01:10 +02:00
|
|
|
# - do_module_delete
|
2021-10-17 23:19:26 +02:00
|
|
|
# - matiere_list
|
2021-07-31 18:01:10 +02:00
|
|
|
# - do_matiere_delete
|
2021-10-17 23:19:26 +02:00
|
|
|
# - ue_list
|
2021-07-31 18:01:10 +02:00
|
|
|
# - do_ue_delete
|
|
|
|
# - do_formation_delete
|
|
|
|
|
|
|
|
import json
|
2021-08-01 15:17:33 +02:00
|
|
|
|
2021-07-31 18:01:10 +02:00
|
|
|
import flask
|
|
|
|
from flask import g
|
2022-01-04 23:05:37 +01:00
|
|
|
import pytest
|
2022-01-15 21:36:06 +01:00
|
|
|
from app.models.moduleimpls import ModuleImpl
|
2021-07-31 18:01:10 +02:00
|
|
|
from tests.unit import sco_fake_gen
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
from app.scodoc import sco_edit_formation, sco_formsemestre
|
2021-07-31 18:01:10 +02:00
|
|
|
from app.scodoc import sco_edit_matiere
|
|
|
|
from app.scodoc import sco_edit_module
|
|
|
|
from app.scodoc import sco_edit_ue
|
2022-01-04 23:05:37 +01:00
|
|
|
from app.scodoc import sco_exceptions
|
2021-07-31 18:01:10 +02:00
|
|
|
from app.scodoc import sco_formations
|
|
|
|
from app.scodoc import sco_formsemestre_edit
|
|
|
|
from app.scodoc import sco_moduleimpl
|
|
|
|
from app.views import notes
|
|
|
|
|
|
|
|
|
|
|
|
def test_formations(test_client):
|
|
|
|
"""Test création/édition/import/export formations"""
|
|
|
|
G = sco_fake_gen.ScoFake(verbose=False)
|
|
|
|
|
|
|
|
# --- Création de formations
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
formation_id = G.create_formation(
|
2021-07-31 18:01:10 +02:00
|
|
|
acronyme="F1", titre="Formation 1", titre_officiel="Titre officiel 1"
|
|
|
|
)
|
2022-01-15 21:36:06 +01:00
|
|
|
f = sco_formations.formation_list(formation_id)[0]
|
|
|
|
ue_id = G.create_ue(formation_id=formation_id, acronyme="TST1", titre="ue test")
|
|
|
|
matiere_id = G.create_matiere(ue_id=ue_id, titre="matière test")
|
|
|
|
module_id = G.create_module(
|
|
|
|
matiere_id=matiere_id,
|
2021-07-31 18:01:10 +02:00
|
|
|
code="TSM1",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test",
|
2022-01-15 21:36:06 +01:00
|
|
|
ue_id=ue_id, # faiblesse de l'API
|
|
|
|
formation_id=formation_id, # faiblesse de l'API
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
ue_id2 = G.create_ue(formation_id=formation_id, acronyme="TST2", titre="ue test2")
|
|
|
|
matiere_id2 = G.create_matiere(ue_id=ue_id2, titre="matière test2")
|
|
|
|
module_id2 = G.create_module(
|
|
|
|
matiere_id=matiere_id2,
|
2021-07-31 18:01:10 +02:00
|
|
|
code="TSM2",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test",
|
2022-01-15 21:36:06 +01:00
|
|
|
ue_id=ue_id2,
|
|
|
|
formation_id=formation_id,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
uet_id = G.create_ue(formation_id=formation_id, acronyme="TSTt", titre="ue testt")
|
|
|
|
matiere_id3 = G.create_matiere(ue_id=uet_id, titre="matière testt")
|
|
|
|
module_id_t = G.create_module(
|
|
|
|
matiere_id=matiere_id3,
|
2021-07-31 18:01:10 +02:00
|
|
|
code="TSMt",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test",
|
2022-01-15 21:36:06 +01:00
|
|
|
ue_id=uet_id,
|
|
|
|
formation_id=formation_id,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
formation_id2 = G.create_formation(acronyme="", titre="Formation test")
|
|
|
|
formation2 = sco_formations.formation_list(formation_id2)[0]
|
|
|
|
ue3 = G.create_ue(formation_id=formation_id2, acronyme="TST3", titre="ue test3")
|
|
|
|
matiere_id4 = G.create_matiere(ue_id=ue3, titre="matière test3")
|
|
|
|
module_id3 = G.create_module(
|
|
|
|
matiere_id=matiere_id4,
|
2021-07-31 18:01:10 +02:00
|
|
|
code="TSM3",
|
|
|
|
coefficient=1.0,
|
|
|
|
titre="module test3",
|
2022-01-15 21:36:06 +01:00
|
|
|
ue_id=ue3,
|
|
|
|
formation_id=formation_id2,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# --- Création et implémentation des semestres
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id1 = G.create_formsemestre(
|
|
|
|
formation_id=formation_id,
|
2021-07-31 18:01:10 +02:00
|
|
|
semestre_id=1,
|
|
|
|
date_debut="01/01/2021",
|
|
|
|
date_fin="30/06/2021",
|
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id2 = G.create_formsemestre(
|
|
|
|
formation_id=formation_id,
|
2021-07-31 18:01:10 +02:00
|
|
|
semestre_id=2,
|
|
|
|
date_debut="01/09/2020",
|
|
|
|
date_fin="31/12/2020",
|
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
moduleimpl_id = G.create_moduleimpl(
|
|
|
|
module_id=module_id,
|
|
|
|
formsemestre_id=formsemestre_id1,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
_ = G.create_moduleimpl(
|
|
|
|
module_id=module_id2,
|
|
|
|
formsemestre_id=formsemestre_id1,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
_ = G.create_moduleimpl(
|
|
|
|
module_id=module_id_t,
|
|
|
|
formsemestre_id=formsemestre_id2,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_idt = G.create_formsemestre(
|
|
|
|
formation_id=formation_id2,
|
2021-07-31 18:01:10 +02:00
|
|
|
semestre_id=3,
|
|
|
|
date_debut="01/01/2021",
|
|
|
|
date_fin="30/06/2021",
|
|
|
|
)
|
|
|
|
|
|
|
|
mi3 = G.create_moduleimpl(
|
2022-01-15 21:36:06 +01:00
|
|
|
module_id=module_id3,
|
|
|
|
formsemestre_id=formsemestre_idt,
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# --- Afficher la liste des formations
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
lif = notes.formation_list(format="json", formation_id=formation_id)
|
2021-07-31 18:01:10 +02:00
|
|
|
# lif est une Response car on a appelé une vue (1er appel)
|
|
|
|
assert isinstance(lif, flask.Response)
|
|
|
|
load_lif = json.loads(lif.get_data().decode("utf-8"))
|
|
|
|
assert len(load_lif) == 1
|
|
|
|
assert load_lif[0]["acronyme"] == f["acronyme"]
|
|
|
|
assert load_lif[0]["titre_officiel"] == f["titre_officiel"]
|
2022-01-15 21:36:06 +01:00
|
|
|
assert load_lif[0]["formation_id"] == formation_id
|
2021-07-31 18:01:10 +02:00
|
|
|
assert load_lif[0]["titre"] == f["titre"]
|
|
|
|
|
2021-09-21 16:34:58 +02:00
|
|
|
lif2 = notes.formation_list(format="json").get_data(as_text=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
# lif2 est un chaine
|
|
|
|
assert isinstance(lif2, str)
|
|
|
|
load_lif2 = json.loads(lif2)
|
|
|
|
assert len(load_lif2) == 2
|
|
|
|
assert load_lif2[0] == load_lif[0]
|
2022-01-15 21:36:06 +01:00
|
|
|
assert load_lif2[1]["titre"] == formation2["titre"]
|
2021-07-31 18:01:10 +02:00
|
|
|
|
|
|
|
# --- Export de formation_id
|
|
|
|
|
2021-09-21 16:34:58 +02:00
|
|
|
exp = sco_formations.formation_export(
|
2022-01-15 21:36:06 +01:00
|
|
|
formation_id=formation_id, format="json"
|
2021-09-21 16:34:58 +02:00
|
|
|
).get_data(as_text=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert isinstance(exp, str)
|
|
|
|
load_exp = json.loads(exp)
|
|
|
|
|
|
|
|
assert load_exp["acronyme"] == "F1"
|
|
|
|
assert load_exp["titre_officiel"] == "Titre officiel 1"
|
|
|
|
assert load_exp["titre"] == "Formation 1"
|
|
|
|
assert load_exp["formation_code"] == f["formation_code"]
|
|
|
|
assert len(load_exp["ue"]) == 3
|
|
|
|
assert load_exp["ue"][0]["acronyme"] == "TST1"
|
|
|
|
assert load_exp["ue"][0]["titre"] == "ue test"
|
2022-01-15 21:36:06 +01:00
|
|
|
assert load_exp["formation_id"] == formation_id
|
2021-07-31 18:01:10 +02:00
|
|
|
assert load_exp["formation_code"] == f["formation_code"]
|
|
|
|
|
|
|
|
# --- Liste des semestres
|
|
|
|
|
|
|
|
li_sem1 = notes.formsemestre_list(
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id=formsemestre_id1, format="json"
|
2021-09-21 16:34:58 +02:00
|
|
|
).get_data(as_text=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert isinstance(li_sem1, str)
|
|
|
|
load_li_sem1 = json.loads(li_sem1) # uniquement le semestre 1 dans la liste
|
|
|
|
|
|
|
|
assert len(load_li_sem1) == 1
|
2022-01-15 21:36:06 +01:00
|
|
|
sem1 = sco_formsemestre.get_formsemestre(formsemestre_id1)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert load_li_sem1[0]["date_fin"] == sem1["date_fin"]
|
|
|
|
assert load_li_sem1[0]["semestre_id"] == sem1["semestre_id"]
|
|
|
|
assert load_li_sem1[0]["formation_id"] == sem1["formation_id"]
|
|
|
|
|
|
|
|
li_semf = notes.formsemestre_list(
|
2022-01-15 21:36:06 +01:00
|
|
|
formation_id=formation_id,
|
2021-07-31 18:01:10 +02:00
|
|
|
format="json",
|
2021-09-21 16:34:58 +02:00
|
|
|
).get_data(as_text=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert isinstance(li_semf, str)
|
|
|
|
load_li_semf = json.loads(li_semf)
|
|
|
|
|
|
|
|
assert load_li_sem1[0] in load_li_semf
|
|
|
|
assert len(load_li_semf) == 2
|
2022-01-15 21:36:06 +01:00
|
|
|
sem2 = sco_formsemestre.get_formsemestre(formsemestre_id2)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert load_li_semf[1]["semestre_id"] == sem2["semestre_id"]
|
|
|
|
|
2021-09-21 16:34:58 +02:00
|
|
|
li_sem = notes.formsemestre_list(format="json").get_data(as_text=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
load_li_sem = json.loads(li_sem)
|
|
|
|
|
|
|
|
assert len(load_li_sem) == 3
|
|
|
|
assert load_li_semf[0] and load_li_semf[1] in load_li_sem
|
|
|
|
|
|
|
|
# --- Liste des modules
|
|
|
|
|
2021-10-15 14:00:51 +02:00
|
|
|
lim_sem1 = sco_moduleimpl.moduleimpl_list(formsemestre_id=sem1["formsemestre_id"])
|
2021-07-31 18:01:10 +02:00
|
|
|
|
|
|
|
assert len(lim_sem1) == 2
|
2022-01-15 21:36:06 +01:00
|
|
|
assert module_id in (
|
|
|
|
lim_sem1[0]["module_id"],
|
|
|
|
lim_sem1[1]["module_id"],
|
|
|
|
)
|
|
|
|
assert module_id2 in (
|
|
|
|
lim_sem1[0]["module_id"],
|
|
|
|
lim_sem1[1]["module_id"],
|
|
|
|
)
|
2021-07-31 18:01:10 +02:00
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
lim_modid = sco_moduleimpl.moduleimpl_list(module_id=module_id)
|
2021-07-31 18:01:10 +02:00
|
|
|
|
|
|
|
assert len(lim_modid) == 1
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
lim_modimpl_id = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)
|
2021-07-31 18:01:10 +02:00
|
|
|
# print(lim_modimpl_id)
|
|
|
|
|
2021-10-15 14:00:51 +02:00
|
|
|
# ---- Test de moduleimpl_withmodule_list
|
2021-07-31 18:01:10 +02:00
|
|
|
|
|
|
|
assert lim_modid == lim_modimpl_id # doit etre le meme resultat
|
|
|
|
|
2021-10-15 14:00:51 +02:00
|
|
|
liimp_sem1 = sco_moduleimpl.moduleimpl_withmodule_list(
|
2021-08-20 01:09:55 +02:00
|
|
|
formsemestre_id=sem1["formsemestre_id"]
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert len(liimp_sem1) == 2
|
2022-01-15 21:36:06 +01:00
|
|
|
assert module_id in (
|
|
|
|
liimp_sem1[0]["module_id"],
|
|
|
|
liimp_sem1[1]["module_id"],
|
|
|
|
)
|
|
|
|
assert module_id2 in (
|
2021-07-31 18:01:10 +02:00
|
|
|
liimp_sem1[0]["module_id"],
|
|
|
|
liimp_sem1[1]["module_id"],
|
|
|
|
)
|
2021-10-15 14:00:51 +02:00
|
|
|
liimp_sem2 = sco_moduleimpl.moduleimpl_withmodule_list(
|
2021-08-20 01:09:55 +02:00
|
|
|
formsemestre_id=sem2["formsemestre_id"]
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
2022-01-15 21:36:06 +01:00
|
|
|
assert module_id_t == liimp_sem2[0]["module_id"]
|
|
|
|
liimp_modid = sco_moduleimpl.moduleimpl_withmodule_list(module_id=module_id)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert len(liimp_modid) == 1
|
|
|
|
|
2021-10-15 14:00:51 +02:00
|
|
|
liimp_modimplid = sco_moduleimpl.moduleimpl_withmodule_list(
|
2022-01-15 21:36:06 +01:00
|
|
|
moduleimpl_id=moduleimpl_id
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert liimp_modid == liimp_modimplid
|
|
|
|
|
|
|
|
# --- Suppression du module, matiere et ue test du semestre 2
|
|
|
|
|
2022-01-04 23:05:37 +01:00
|
|
|
# on doit d'abord supprimer le semestre:
|
2021-07-31 18:01:10 +02:00
|
|
|
|
|
|
|
sco_formsemestre_edit.do_formsemestre_delete(
|
2021-08-21 00:24:51 +02:00
|
|
|
formsemestre_id=sem2["formsemestre_id"]
|
2021-07-31 18:01:10 +02:00
|
|
|
)
|
|
|
|
|
2021-10-16 19:20:36 +02:00
|
|
|
li_module = sco_edit_module.module_list()
|
2021-07-31 18:01:10 +02:00
|
|
|
assert len(li_module) == 4
|
2022-01-15 21:36:06 +01:00
|
|
|
# Suppression impossible car utilisé dans le semestre formsemestre_idt:
|
|
|
|
module3 = ModuleImpl.query.get(mi3).module
|
2022-01-04 23:05:37 +01:00
|
|
|
with pytest.raises(sco_exceptions.ScoNonEmptyFormationObject):
|
2022-01-15 21:36:06 +01:00
|
|
|
sco_edit_module.module_delete(module_id=module3.id)
|
2022-01-04 23:05:37 +01:00
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
sco_formsemestre_edit.do_formsemestre_delete(formsemestre_idt)
|
2022-01-04 23:05:37 +01:00
|
|
|
|
|
|
|
li_module2_before = sco_edit_module.module_list()
|
|
|
|
|
2022-01-15 21:36:06 +01:00
|
|
|
sco_edit_module.do_module_delete(module3.id)
|
|
|
|
sco_edit_module.do_module_delete(module_id_t)
|
2022-01-04 23:05:37 +01:00
|
|
|
|
2021-07-31 18:01:10 +02:00
|
|
|
# deuxieme methode de supression d'un module
|
2022-01-04 23:05:37 +01:00
|
|
|
li_module2_after = sco_edit_module.module_list()
|
2021-07-31 18:01:10 +02:00
|
|
|
|
2022-01-04 23:05:37 +01:00
|
|
|
assert (
|
|
|
|
len(li_module2_after) == len(li_module2_before) - 2
|
|
|
|
) # verification de la suppression
|
2021-07-31 18:01:10 +02:00
|
|
|
|
2021-10-15 14:00:51 +02:00
|
|
|
lim_sem2 = sco_moduleimpl.moduleimpl_list(formsemestre_id=sem2["formsemestre_id"])
|
2021-07-31 18:01:10 +02:00
|
|
|
|
|
|
|
assert len(lim_sem2) == 0 # deuxieme vérification si le module s'est bien sup
|
|
|
|
|
2021-10-17 23:19:26 +02:00
|
|
|
li_mat = sco_edit_matiere.matiere_list()
|
2021-07-31 18:01:10 +02:00
|
|
|
assert len(li_mat) == 4
|
2022-01-15 21:36:06 +01:00
|
|
|
sco_edit_matiere.do_matiere_delete(oid=matiere_id3) # on supprime la matiere
|
2021-10-17 23:19:26 +02:00
|
|
|
li_mat2 = sco_edit_matiere.matiere_list()
|
2021-07-31 18:01:10 +02:00
|
|
|
assert len(li_mat2) == 3 # verification de la suppression de la matiere
|
|
|
|
|
2021-10-17 23:19:26 +02:00
|
|
|
li_ue = sco_edit_ue.ue_list()
|
2021-07-31 18:01:10 +02:00
|
|
|
assert len(li_ue) == 4
|
2022-01-15 21:36:06 +01:00
|
|
|
sco_edit_ue.ue_delete(ue_id=uet_id, dialog_confirmed=True)
|
2021-10-17 23:19:26 +02:00
|
|
|
li_ue2 = sco_edit_ue.ue_list()
|
2021-07-31 18:01:10 +02:00
|
|
|
assert len(li_ue2) == 3 # verification de la suppression de l'UE
|
|
|
|
|
|
|
|
# --- Suppression d'une formation
|
|
|
|
|
2022-07-13 18:52:07 +02:00
|
|
|
sco_edit_formation.do_formation_delete(formation_id=formation_id2)
|
2021-09-21 16:34:58 +02:00
|
|
|
lif3 = notes.formation_list(format="json").get_data(as_text=True)
|
2021-07-31 18:01:10 +02:00
|
|
|
assert isinstance(lif3, str)
|
|
|
|
load_lif3 = json.loads(lif3)
|
2021-08-01 10:16:16 +02:00
|
|
|
assert len(load_lif3) == 1
|
|
|
|
|
|
|
|
|
|
|
|
def test_import_formation(test_client):
|
|
|
|
"""Test import/export formations"""
|
|
|
|
G = sco_fake_gen.ScoFake(verbose=False)
|
|
|
|
# Lecture fichier XML local:
|
|
|
|
with open("tests/unit/formation-exemple-1.xml") as f:
|
|
|
|
doc = f.read()
|
|
|
|
|
|
|
|
# --- Création de la formation
|
2021-08-20 01:09:55 +02:00
|
|
|
f = sco_formations.formation_import_xml(doc)
|
2021-08-01 10:16:16 +02:00
|
|
|
assert len(f) == 3 # 3-uple
|
|
|
|
formation_id = f[0]
|
2021-10-22 23:09:15 +02:00
|
|
|
# --- Vérification des UE
|
|
|
|
ues = sco_edit_ue.ue_list({"formation_id": formation_id})
|
|
|
|
assert len(ues) == 10
|
|
|
|
assert all(not ue["is_external"] for ue in ues) # aucune UE externe dans le XML
|
2021-08-01 10:16:16 +02:00
|
|
|
# --- Mise en place de 4 semestres
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_ids = [
|
2021-08-01 10:16:16 +02:00
|
|
|
G.create_formsemestre(
|
|
|
|
formation_id=formation_id,
|
|
|
|
semestre_id=x[0],
|
|
|
|
date_debut=x[1],
|
|
|
|
date_fin=x[2],
|
|
|
|
)
|
|
|
|
for x in (
|
|
|
|
(1, "05/09/2019", "05/01/2020"),
|
|
|
|
(2, "06/01/2020", "30/06/2020"),
|
|
|
|
(3, "01/09/2020", "05/01/2021"),
|
|
|
|
(4, "06/01/2021", "30/06/2021"),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
# et les modules
|
2021-10-16 19:20:36 +02:00
|
|
|
modules = sco_edit_module.module_list({"formation_id": formation_id})
|
2021-08-01 10:16:16 +02:00
|
|
|
for mod in modules:
|
2022-01-15 21:36:06 +01:00
|
|
|
moduleimpl_id = G.create_moduleimpl(
|
2021-08-01 10:16:16 +02:00
|
|
|
module_id=mod["module_id"],
|
2022-01-15 21:36:06 +01:00
|
|
|
formsemestre_id=formsemestre_ids[mod["semestre_id"] - 1],
|
2021-08-01 10:16:16 +02:00
|
|
|
)
|
2022-01-15 21:36:06 +01:00
|
|
|
mi = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
|
2021-08-01 15:17:33 +02:00
|
|
|
assert mi["ens"] == []
|
|
|
|
assert mi["module_id"] == mod["module_id"]
|
|
|
|
|
|
|
|
# --- Export formation en XML
|
2021-09-21 16:34:58 +02:00
|
|
|
doc1 = sco_formations.formation_export(formation_id, format="xml").get_data(
|
|
|
|
as_text=True
|
|
|
|
)
|
2021-08-01 15:17:33 +02:00
|
|
|
assert isinstance(doc1, str)
|