forked from ScoDoc/ScoDoc
Nouveau test unitaire sur les formsemestres
This commit is contained in:
parent
639941bc37
commit
4c7c6e1be0
93
tests/ressources/yaml/simple_formsemestres.yaml
Normal file
93
tests/ressources/yaml/simple_formsemestres.yaml
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# Définion de deux formsemestres dans la même formation, sans résultats
|
||||||
|
# pour tests unitaires formsemestre.
|
||||||
|
|
||||||
|
Formation:
|
||||||
|
filename: scodoc_formation_BUT_GEII_lyon_v1.xml
|
||||||
|
# Association des UE aux compétences:
|
||||||
|
ues:
|
||||||
|
# S1 : Tronc commun GEII
|
||||||
|
'UE11':
|
||||||
|
annee: BUT1
|
||||||
|
competence: Concevoir
|
||||||
|
'UE12':
|
||||||
|
annee: BUT1
|
||||||
|
competence: Vérifier
|
||||||
|
|
||||||
|
# S2 : Tronc commun GEII
|
||||||
|
'UE21':
|
||||||
|
annee: BUT1
|
||||||
|
competence: Concevoir
|
||||||
|
'UE22':
|
||||||
|
annee: BUT1
|
||||||
|
competence: Vérifier
|
||||||
|
|
||||||
|
# S3 : Tronc commun GEII
|
||||||
|
'UE31':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Concevoir
|
||||||
|
'UE32':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Vérifier
|
||||||
|
'UE33':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Maintenir
|
||||||
|
# S3 : Parcours EME
|
||||||
|
'UE34EME':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Installer
|
||||||
|
parcours: EME
|
||||||
|
# S3 : Parcours ESE
|
||||||
|
'UE34ESE':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Implanter
|
||||||
|
parcours: ESE
|
||||||
|
# S3 : Parcours AII
|
||||||
|
'UE34AII':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Intégrer
|
||||||
|
parcours: AII
|
||||||
|
|
||||||
|
# S4 : Tronc commun GEII
|
||||||
|
'UE41':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Concevoir
|
||||||
|
'UE42':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Vérifier
|
||||||
|
'UE43':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Maintenir
|
||||||
|
# S4 : Parcours EME
|
||||||
|
'UE44EME':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Installer
|
||||||
|
parcours: EME
|
||||||
|
# S4 : Parcours ESE
|
||||||
|
'UE44ESE':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Implanter
|
||||||
|
parcours: ESE
|
||||||
|
# S4 : Parcours AII
|
||||||
|
'UE44AII':
|
||||||
|
annee: BUT2
|
||||||
|
competence: Intégrer
|
||||||
|
parcours: AII
|
||||||
|
|
||||||
|
modules_parcours:
|
||||||
|
# cette section permet d'associer des modules à des parcours
|
||||||
|
# les codes modules peuvent être des regexp
|
||||||
|
EME: [ .*EME.* ]
|
||||||
|
ESE: [ .*ESE.* ]
|
||||||
|
AII: [ .*AII.* ]
|
||||||
|
|
||||||
|
FormSemestres:
|
||||||
|
# S1 et S2 :
|
||||||
|
S1:
|
||||||
|
idx: 1
|
||||||
|
date_debut: 2021-09-01
|
||||||
|
date_fin: 2022-01-15
|
||||||
|
S1b:
|
||||||
|
idx: 1
|
||||||
|
date_debut: 2021-09-02
|
||||||
|
date_fin: 2022-01-17
|
||||||
|
|
36
tests/unit/test_formsemestre.py
Normal file
36
tests/unit/test_formsemestre.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# -*- mode: python -*-
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
""" Test création/accès/clonage formsemestre
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
from tests.unit import yaml_setup
|
||||||
|
|
||||||
|
import app
|
||||||
|
from app.models import Formation
|
||||||
|
from app.scodoc import sco_formsemestre_edit
|
||||||
|
from config import TestConfig
|
||||||
|
|
||||||
|
DEPT = TestConfig.DEPT_TEST
|
||||||
|
|
||||||
|
|
||||||
|
def test_formsemestres_associate_new_version(test_client):
|
||||||
|
"""Test association à une nouvelle version du programme"""
|
||||||
|
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()
|
||||||
|
formsemestres = formation.formsemestres.all()
|
||||||
|
# On a deux S1:
|
||||||
|
assert len(formsemestres) == 2
|
||||||
|
assert {s.semestre_id for s in formsemestres} == {1}
|
||||||
|
# Les rattache à une nouvelle version de la formation:
|
||||||
|
formsemestre_ids = [s.id for s in formsemestres]
|
||||||
|
sco_formsemestre_edit.do_formsemestres_associate_new_version(formsemestre_ids)
|
||||||
|
new_formation: Formation = Formation.query.filter_by(
|
||||||
|
acronyme="BUT GEII", version=2
|
||||||
|
).first()
|
||||||
|
assert new_formation
|
||||||
|
assert formsemestres[0].formation_id == new_formation.id
|
||||||
|
assert formsemestres[1].formation_id == new_formation.id
|
@ -234,7 +234,10 @@ def setup_formsemestres(formation: Formation, doc: str):
|
|||||||
|
|
||||||
def inscrit_les_etudiants(formation: Formation, doc: dict):
|
def inscrit_les_etudiants(formation: Formation, doc: dict):
|
||||||
"""Inscrit les étudiants dans chacun de leurs formsemestres"""
|
"""Inscrit les étudiants dans chacun de leurs formsemestres"""
|
||||||
for nom, infos in doc["Etudiants"].items():
|
etudiants = doc.get("Etudiants")
|
||||||
|
if not etudiants:
|
||||||
|
return
|
||||||
|
for nom, infos in etudiants.items():
|
||||||
etud = Identite.create_etud(
|
etud = Identite.create_etud(
|
||||||
dept_id=g.scodoc_dept_id,
|
dept_id=g.scodoc_dept_id,
|
||||||
nom=nom,
|
nom=nom,
|
||||||
@ -283,6 +286,8 @@ def setup_from_yaml(filename: str) -> dict:
|
|||||||
)
|
)
|
||||||
yaml_setup_but.associe_ues_et_parcours(formation, doc["Formation"])
|
yaml_setup_but.associe_ues_et_parcours(formation, doc["Formation"])
|
||||||
setup_formsemestres(formation, doc)
|
setup_formsemestres(formation, doc)
|
||||||
|
etudiants = doc.get("Etudiants")
|
||||||
|
if etudiants:
|
||||||
inscrit_les_etudiants(formation, doc)
|
inscrit_les_etudiants(formation, doc)
|
||||||
note_les_modules(doc)
|
note_les_modules(doc)
|
||||||
return doc
|
return doc
|
||||||
|
Loading…
Reference in New Issue
Block a user