2021-08-07 16:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2022-03-09 16:05:44 +01:00
|
|
|
"""XXX OBSOLETE
|
|
|
|
|
2021-08-07 16:33:47 +02:00
|
|
|
Scenario: préparation base de données pour tests Selenium
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-08-07 16:33:47 +02:00
|
|
|
S'utilise comme un test avec pytest, mais n'est pas un test !
|
|
|
|
Modifie la base de données du département TEST00
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-08-07 16:33:47 +02:00
|
|
|
Usage: pytest tests/scenarios/test_scenario1_formation.py
|
|
|
|
"""
|
|
|
|
# code écrit par Fares Amer, mai 2021 et porté sur ScoDoc 8 en août 2021
|
2021-07-02 12:34:44 +02:00
|
|
|
|
2021-08-07 16:33:47 +02:00
|
|
|
from tests.unit import sco_fake_gen
|
2024-10-10 00:41:20 +02:00
|
|
|
from app.formations import edit_module, formation_io
|
2021-08-07 16:33:47 +02:00
|
|
|
|
|
|
|
|
2024-02-11 21:19:45 +01:00
|
|
|
@pytest.mark.skip # test obsolete
|
2021-08-07 16:33:47 +02:00
|
|
|
def test_scenario1(test_client):
|
|
|
|
"""Applique "scenario 1"""
|
2021-08-10 12:57:38 +02:00
|
|
|
run_scenario1()
|
|
|
|
|
|
|
|
|
|
|
|
def run_scenario1():
|
2021-08-07 16:33:47 +02:00
|
|
|
G = sco_fake_gen.ScoFake(verbose=False)
|
|
|
|
|
|
|
|
# Lecture fichier XML local:
|
2024-02-11 21:19:45 +01:00
|
|
|
with open(
|
|
|
|
"tests/ressources/formations/formation-exemple-1.xml", encoding="utf8"
|
|
|
|
) as f:
|
2021-08-07 16:33:47 +02:00
|
|
|
doc = f.read()
|
|
|
|
|
|
|
|
# --- Création de la formation
|
2024-10-10 00:41:20 +02:00
|
|
|
f = formation_io.formation_import_xml(doc=doc)
|
2021-08-07 16:33:47 +02:00
|
|
|
|
|
|
|
# --- Création des semestres
|
|
|
|
formation_id = f[0]
|
|
|
|
# --- Mise en place de 4 semestres
|
|
|
|
sems = [
|
|
|
|
G.create_formsemestre(
|
|
|
|
formation_id=formation_id,
|
|
|
|
semestre_id=x[0],
|
|
|
|
date_debut=x[1],
|
|
|
|
date_fin=x[2],
|
|
|
|
)
|
|
|
|
for x in (
|
|
|
|
(1, "01/09/2020", "01/02/2021"),
|
|
|
|
(2, "02/02/2021", "01/06/2021"),
|
|
|
|
(3, "01/09/2020", "01/02/2021"),
|
|
|
|
(4, "02/02/2021", "01/06/2021"),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
# --- Implémentation des modules
|
2024-10-10 00:41:20 +02:00
|
|
|
modules = edit_module.module_list({"formation_id": formation_id})
|
2021-08-07 16:33:47 +02:00
|
|
|
mods_imp = []
|
|
|
|
for mod in modules:
|
|
|
|
mi = G.create_moduleimpl(
|
|
|
|
module_id=mod["module_id"],
|
|
|
|
formsemestre_id=sems[mod["semestre_id"] - 1]["formsemestre_id"],
|
|
|
|
)
|
|
|
|
mods_imp.append(mi)
|