From 0dda9157ebf2bf299bb2200b7681fbe099af14e6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 1 Jul 2023 12:36:30 +0200 Subject: [PATCH] Adapte tests unitaires - OK --- tests/unit/test_but_cursus.py | 16 ++++++++++++++-- tests/unit/test_formsemestre.py | 22 +++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/tests/unit/test_but_cursus.py b/tests/unit/test_but_cursus.py index 12b54be1..293e6d24 100644 --- a/tests/unit/test_but_cursus.py +++ b/tests/unit/test_but_cursus.py @@ -31,7 +31,13 @@ def test_cursus_but_jury_gb(test_client): app.set_sco_dept(DEPT) # login_user(User.query.filter_by(user_name="admin").first()) # XXX pour tests manuels # ctx.push() # XXX - doc = yaml_setup.setup_from_yaml("tests/ressources/yaml/cursus_but_gb.yaml") + doc, formation, formsemestre_titres = yaml_setup.setup_from_yaml( + "tests/ressources/yaml/cursus_but_gb.yaml" + ) + for formsemestre_titre in formsemestre_titres: + formsemestre = yaml_setup.create_formsemestre_with_etuds( + doc, formation, formsemestre_titre + ) formsemestre: FormSemestre = FormSemestre.query.filter_by(titre="S3").first() res: ResultatsSemestreBUT = res_sem.load_formsemestre_results(formsemestre) cursus = FormSemestreCursusBUT(res) @@ -72,7 +78,13 @@ def test_refcomp_niveaux_info(test_client): # WIP # pour le moment juste le chargement de la formation, du ref. comp, et des UE du S4. app.set_sco_dept(DEPT) - doc = yaml_setup.setup_from_yaml("tests/ressources/yaml/cursus_but_info.yaml") + doc, formation, formsemestre_titres = yaml_setup.setup_from_yaml( + "tests/ressources/yaml/cursus_but_info.yaml" + ) + for formsemestre_titre in formsemestre_titres: + formsemestre = yaml_setup.create_formsemestre_with_etuds( + doc, formation, formsemestre_titre + ) formsemestre: FormSemestre = FormSemestre.query.filter_by(titre="S4").first() assert formsemestre res: ResultatsSemestreBUT = res_sem.load_formsemestre_results(formsemestre) diff --git a/tests/unit/test_formsemestre.py b/tests/unit/test_formsemestre.py index 02945044..1af482eb 100644 --- a/tests/unit/test_formsemestre.py +++ b/tests/unit/test_formsemestre.py @@ -44,9 +44,18 @@ def test_formsemestres_associate_new_version(test_client): app.set_sco_dept(DEPT) # Construit la base de test GB une seule fois # puis lance les tests de jury - yaml_setup.setup_from_yaml("tests/ressources/yaml/simple_formsemestres.yaml") - formation = Formation.query.filter_by(acronyme="BUT GEII", version=1).first() + doc, formation, formsemestre_titres = yaml_setup.setup_from_yaml( + "tests/ressources/yaml/simple_formsemestres.yaml" + ) + for formsemestre_titre in formsemestre_titres: + formsemestre = yaml_setup.create_formsemestre_with_etuds( + doc, formation, formsemestre_titre + ) + assert formsemestre + formation_geii = Formation.query.filter_by(acronyme="BUT GEII", version=1).first() + assert formation_geii.id == formation.id formsemestres = formation.formsemestres.all() + assert len(formsemestres) == len(formsemestre_titres) # On a deux S1: assert len(formsemestres) == 2 assert {s.semestre_id for s in formsemestres} == {1} @@ -70,7 +79,14 @@ def test_formsemestre_misc_views(test_client): Note: les anciennes vues renvoient souvent des str au lieu de Response. """ app.set_sco_dept(DEPT) - yaml_setup.setup_from_yaml("tests/ressources/yaml/simple_formsemestres.yaml") + doc, formation, formsemestre_titres = yaml_setup.setup_from_yaml( + "tests/ressources/yaml/simple_formsemestres.yaml" + ) + for formsemestre_titre in formsemestre_titres: + formsemestre = yaml_setup.create_formsemestre_with_etuds( + doc, formation, formsemestre_titre + ) + assert formsemestre formsemestre: FormSemestre = FormSemestre.query.first() # ----- MENU SEMESTRE