forked from ScoDoc/ScoDoc
pseudo-test pour initalisation Selenium
This commit is contained in:
parent
06f66e6976
commit
bf0b2c66bd
@ -1,73 +1,61 @@
|
|||||||
import sco_formations
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Scenario: préparation base de données pour tests Selenium
|
||||||
|
|
||||||
|
S'utilise comme un test avec pytest, mais n'est pas un test !
|
||||||
|
Modifie la base de données du département TEST00
|
||||||
|
|
||||||
|
Usage: pytest tests/scenarios/test_scenario1_formation.py
|
||||||
|
"""
|
||||||
|
# code écrit par Fares Amer, mai 2021 et porté sur ScoDoc 8 en août 2021
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
# La variable context est définie par le script de lancement
|
from tests.unit import sco_fake_gen
|
||||||
# l'affecte ainsi pour évietr les warnins pylint:
|
from app.scodoc import sco_edit_module
|
||||||
context = context # pylint: disable=undefined-variable
|
from app.scodoc import sco_formations
|
||||||
REQUEST = REQUEST # pylint: disable=undefined-variable
|
from app.scodoc import sco_moduleimpl
|
||||||
import scotests.sco_fake_gen as sco_fake_gen # pylint: disable=import-error
|
|
||||||
import sco_moduleimpl
|
|
||||||
|
|
||||||
G = sco_fake_gen.ScoFake(context.Notes)
|
context = None # #context
|
||||||
G.verbose = False
|
|
||||||
|
|
||||||
file = open("scotests/export_formation1.xml")
|
|
||||||
doc = file.read()
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
def test_scenario1(test_client):
|
||||||
|
"""Applique "scenario 1"""
|
||||||
|
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
|
# --- Création de la formation
|
||||||
|
f = sco_formations.formation_import_xml(doc=doc, context=context)
|
||||||
f = sco_formations.formation_import_xml(doc=doc, context=context.Notes)
|
|
||||||
|
|
||||||
# --- Création des semestres
|
# --- Création des semestres
|
||||||
|
formation_id = f[0]
|
||||||
sem1 = G.create_formsemestre(
|
# --- Mise en place de 4 semestres
|
||||||
formation_id=f[0],
|
sems = [
|
||||||
semestre_id=1,
|
G.create_formsemestre(
|
||||||
date_debut="01/09/2020",
|
formation_id=formation_id,
|
||||||
date_fin="01/02/2021",
|
semestre_id=x[0],
|
||||||
|
date_debut=x[1],
|
||||||
|
date_fin=x[2],
|
||||||
)
|
)
|
||||||
|
for x in (
|
||||||
sem3 = G.create_formsemestre(
|
(1, "01/09/2020", "01/02/2021"),
|
||||||
formation_id=f[0],
|
(2, "02/02/2021", "01/06/2021"),
|
||||||
semestre_id=3,
|
(3, "01/09/2020", "01/02/2021"),
|
||||||
date_debut="01/09/2020",
|
(4, "02/02/2021", "01/06/2021"),
|
||||||
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
|
# --- Implémentation des modules
|
||||||
|
modules = sco_edit_module.do_module_list(context, {"formation_id": formation_id})
|
||||||
li_module = context.Notes.do_module_list()
|
|
||||||
mods_imp = []
|
mods_imp = []
|
||||||
for mod in li_module:
|
for mod in modules:
|
||||||
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(
|
mi = G.create_moduleimpl(
|
||||||
module_id=mod["module_id"],
|
module_id=mod["module_id"],
|
||||||
formsemestre_id=formsemestre_id,
|
formsemestre_id=sems[mod["semestre_id"] - 1]["formsemestre_id"],
|
||||||
responsable_id="bach",
|
responsable_id="bach",
|
||||||
)
|
)
|
||||||
mods_imp.append(mi)
|
mods_imp.append(mi)
|
Loading…
Reference in New Issue
Block a user