From 12e14dc6df126aff01880d269471b8ac90815bd4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 19 Oct 2023 23:47:04 +0200 Subject: [PATCH] Fix unit tests --- tests/unit/sco_fake_gen.py | 5 ++--- tests/unit/setup.py | 3 +-- tests/unit/yaml_setup.py | 9 ++++++++- tests/unit/yaml_setup_but.py | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/unit/sco_fake_gen.py b/tests/unit/sco_fake_gen.py index 1f2dff8b..fe5b700a 100644 --- a/tests/unit/sco_fake_gen.py +++ b/tests/unit/sco_fake_gen.py @@ -25,7 +25,6 @@ from app.models import ( Matiere, ModuleImpl, ) -from app.scodoc import notesdb as ndb from app.scodoc import codes_cursus from app.scodoc import sco_edit_matiere from app.scodoc import sco_edit_module @@ -41,8 +40,6 @@ from app.scodoc.sco_exceptions import ScoValueError from config import Config, TestConfig -from tests.unit.setup import NOTES_T - random.seed(12345) # tests reproductibles @@ -433,6 +430,8 @@ class ScoFake(object): notes: liste des notes (float). Si non spécifié, utilise la liste NOTES_T """ + from tests.unit.setup import NOTES_T + if notes is None: notes = NOTES_T for e in eval_list: diff --git a/tests/unit/setup.py b/tests/unit/setup.py index 77621035..31ea1496 100644 --- a/tests/unit/setup.py +++ b/tests/unit/setup.py @@ -7,14 +7,13 @@ from app import db, models from app.models import Formation import app.scodoc.sco_utils as scu from app.scodoc import codes_cursus +from tests.unit import sco_fake_gen # Valeurs des notes saisies par les tests: NOTES_T = [ float(x) for x in (20, 0, 10, 13 / 7.0, 12.5, 24.0 / 11) + tuple(range(1, 19)) ] -from tests.unit import sco_fake_gen - def build_formation_test( nb_mods=1, diff --git a/tests/unit/yaml_setup.py b/tests/unit/yaml_setup.py index 577855ba..6140537c 100644 --- a/tests/unit/yaml_setup.py +++ b/tests/unit/yaml_setup.py @@ -127,7 +127,7 @@ def create_formsemestre( modules = [ m for m in formsemestre.formation.modules.filter_by(semestre_id=semestre_id) - if (not m.parcours) # module de tronc commun + if not m.parcours # module de tronc commun or (not sem_parcours_ids) # semestre sans parcours => tous or ({p.id for p in m.parcours} & sem_parcours_ids) ] @@ -329,6 +329,13 @@ def setup_from_yaml(filename: str) -> tuple[dict, Formation, list[str]]: with open(filename, encoding="utf-8") as f: doc = yaml.safe_load(f.read()) + # Passe tous les noms en majuscules (car stockés ainsi en base) + if "Etudiants" in doc: + doc["Etudiants"] = {k.upper(): v for (k, v) in doc["Etudiants"].items()} + for e in doc["Etudiants"].values(): + if "prenom" in e: + e["prenom"] = e["prenom"].upper() + # Charge de ref. comp. avant la formation, de façon à pouvoir # re-créer les associations UE/Niveaux yaml_setup_but.setup_formation_referentiel(doc.get("ReferentielCompetences", {})) diff --git a/tests/unit/yaml_setup_but.py b/tests/unit/yaml_setup_but.py index d87ca135..0198fcf6 100644 --- a/tests/unit/yaml_setup_but.py +++ b/tests/unit/yaml_setup_but.py @@ -4,7 +4,7 @@ # See LICENSE ############################################################################## -"""Mise en place pour tests unitaires à partir de descriptions YAML: +"""Mise en place pour tests unitaires à partir de descriptions YAML: fonctions spécifiques au BUT """ from pathlib import Path