forked from ScoDoc/ScoDoc
WIP: mise à jour des tests unitaires
This commit is contained in:
parent
63c0667694
commit
2bf678ac50
@ -14,6 +14,7 @@ from app.scodoc import sco_abs
|
|||||||
from app.scodoc import sco_abs_views
|
from app.scodoc import sco_abs_views
|
||||||
from app.scodoc import sco_groups
|
from app.scodoc import sco_groups
|
||||||
from app.scodoc import sco_formsemestre
|
from app.scodoc import sco_formsemestre
|
||||||
|
from app.scodoc import sco_preferences
|
||||||
from app.views import absences
|
from app.views import absences
|
||||||
|
|
||||||
|
|
||||||
@ -313,6 +314,8 @@ def test_abs_basic(test_client):
|
|||||||
assert un_etud["nomprenom"] == etuds[0]["nomprenom"]
|
assert un_etud["nomprenom"] == etuds[0]["nomprenom"]
|
||||||
|
|
||||||
# --- Création de billets
|
# --- Création de billets
|
||||||
|
# Active la gestion de billets:
|
||||||
|
sco_preferences.get_base_preferences().set(None, "handle_billets_abs", 1)
|
||||||
|
|
||||||
b1 = absences.AddBilletAbsence(
|
b1 = absences.AddBilletAbsence(
|
||||||
begin="2021-01-22 00:00",
|
begin="2021-01-22 00:00",
|
||||||
@ -338,4 +341,7 @@ def test_abs_basic(test_client):
|
|||||||
load_li_bi = json.loads(li_bi)
|
load_li_bi = json.loads(li_bi)
|
||||||
|
|
||||||
assert len(load_li_bi) == 2
|
assert len(load_li_bi) == 2
|
||||||
assert load_li_bi[1]["description"] == "abs du 22"
|
assert (
|
||||||
|
load_li_bi[1]["description"] == "abs du 15"
|
||||||
|
or load_li_bi[1]["description"] == "abs du 22"
|
||||||
|
)
|
||||||
|
@ -41,14 +41,14 @@ def test_notes_table(test_client): # XXX A REVOIR POUR TESTER RES TODO
|
|||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
assert nt
|
assert nt
|
||||||
assert sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
assert sco_cache.ResultatsSemestreCache.get(formsemestre_id)
|
||||||
sco_cache.invalidate_formsemestre(formsemestre_id)
|
sco_cache.invalidate_formsemestre(formsemestre_id)
|
||||||
assert not sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
assert not sco_cache.ResultatsSemestreCache.get(formsemestre_id)
|
||||||
# cache les 10 premiers
|
# cache les 10 premiers
|
||||||
for sem in sems[:10]:
|
for sem in sems[:10]:
|
||||||
formsemestre_id = sem["formsemestre_id"]
|
formsemestre_id = sem["formsemestre_id"]
|
||||||
nt = sco_cache.NotesTableCache.get(formsemestre_id)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
assert sco_cache.NotesTableCache.get(formsemestre_id, compute=False)
|
assert sco_cache.ResultatsSemestreCache.get(formsemestre_id)
|
||||||
|
|
||||||
|
|
||||||
def test_cache_evaluations(test_client):
|
def test_cache_evaluations(test_client):
|
||||||
|
@ -2,23 +2,19 @@
|
|||||||
Vérif moyennes de modules des bulletins
|
Vérif moyennes de modules des bulletins
|
||||||
et aussi moyennes modules et UE internes (via nt)
|
et aussi moyennes modules et UE internes (via nt)
|
||||||
"""
|
"""
|
||||||
|
import numpy as np
|
||||||
from re import X
|
from flask import g
|
||||||
from config import TestConfig
|
from config import TestConfig
|
||||||
from tests.unit import sco_fake_gen
|
from tests.unit import sco_fake_gen
|
||||||
|
|
||||||
from flask import g
|
|
||||||
|
|
||||||
import app
|
import app
|
||||||
from app.comp import res_sem
|
from app.comp import res_sem
|
||||||
from app.comp.res_compat import NotesTableCompat
|
from app.comp.res_compat import NotesTableCompat
|
||||||
from app.models import FormSemestre
|
from app.models import FormSemestre
|
||||||
from app.scodoc import sco_bulletins, sco_formsemestre
|
from app.scodoc import sco_bulletins, sco_formsemestre
|
||||||
from app.scodoc import sco_cache
|
|
||||||
from app.scodoc import sco_formsemestre_inscriptions
|
from app.scodoc import sco_formsemestre_inscriptions
|
||||||
from app.scodoc import sco_moduleimpl
|
from app.scodoc import sco_moduleimpl
|
||||||
from app.scodoc import sco_utils as scu
|
from app.scodoc import sco_utils as scu
|
||||||
from app.views import scolar
|
|
||||||
|
|
||||||
DEPT = TestConfig.DEPT_TEST
|
DEPT = TestConfig.DEPT_TEST
|
||||||
|
|
||||||
@ -30,7 +26,6 @@ def check_nt(
|
|||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_moy_ue=False,
|
expected_moy_ue=False,
|
||||||
expected_mod_moy=False,
|
expected_mod_moy=False,
|
||||||
expected_sum_coefs_ue=False,
|
|
||||||
):
|
):
|
||||||
"""Vérification bas niveau: vérif resultat avec l'API internet "nt"
|
"""Vérification bas niveau: vérif resultat avec l'API internet "nt"
|
||||||
(peut changer dans le futur, ne pas utiliser hors ScoDoc !)
|
(peut changer dans le futur, ne pas utiliser hors ScoDoc !)
|
||||||
@ -41,12 +36,16 @@ def check_nt(
|
|||||||
mod_moy = nt.get_etud_mod_moy(moduleimpl_id, etudid)
|
mod_moy = nt.get_etud_mod_moy(moduleimpl_id, etudid)
|
||||||
if expected_moy_ue is not False:
|
if expected_moy_ue is not False:
|
||||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
||||||
|
if np.isnan(expected_moy_ue):
|
||||||
|
assert np.isnan(ue_status["moy"])
|
||||||
|
else:
|
||||||
assert expected_moy_ue == ue_status["moy"]
|
assert expected_moy_ue == ue_status["moy"]
|
||||||
if expected_mod_moy is not False:
|
if expected_mod_moy is not False:
|
||||||
|
if not isinstance(expected_mod_moy, str) and np.isnan(expected_mod_moy):
|
||||||
|
assert np.isnan(mod_moy)
|
||||||
|
else:
|
||||||
assert expected_mod_moy == mod_moy
|
assert expected_mod_moy == mod_moy
|
||||||
if expected_sum_coefs_ue is not False:
|
|
||||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
|
||||||
assert expected_sum_coefs_ue == ue_status["sum_coefs"]
|
|
||||||
return nt
|
return nt
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +129,6 @@ def test_notes_modules(test_client):
|
|||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy=note_th,
|
expected_mod_moy=note_th,
|
||||||
expected_moy_ue=note_th,
|
expected_moy_ue=note_th,
|
||||||
expected_sum_coefs_ue=coef_mod_1,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Absence à une évaluation
|
# Absence à une évaluation
|
||||||
@ -155,7 +153,6 @@ def test_notes_modules(test_client):
|
|||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy=0.0,
|
expected_mod_moy=0.0,
|
||||||
expected_moy_ue=0.0,
|
expected_moy_ue=0.0,
|
||||||
expected_sum_coefs_ue=coef_mod_1, # absences, donc zéros et on garde le coef
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Note excusée EXC <-> scu.NOTES_NEUTRALISE
|
# Note excusée EXC <-> scu.NOTES_NEUTRALISE
|
||||||
@ -172,7 +169,6 @@ def test_notes_modules(test_client):
|
|||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy=note_1,
|
expected_mod_moy=note_1,
|
||||||
expected_moy_ue=note_1,
|
expected_moy_ue=note_1,
|
||||||
expected_sum_coefs_ue=coef_mod_1,
|
|
||||||
)
|
)
|
||||||
# Note en attente ATT <-> scu.NOTES_ATTENTE
|
# Note en attente ATT <-> scu.NOTES_ATTENTE
|
||||||
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=note_1)
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=note_1)
|
||||||
@ -188,7 +184,6 @@ def test_notes_modules(test_client):
|
|||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy=note_1,
|
expected_mod_moy=note_1,
|
||||||
expected_moy_ue=note_1,
|
expected_moy_ue=note_1,
|
||||||
expected_sum_coefs_ue=coef_mod_1,
|
|
||||||
)
|
)
|
||||||
# Neutralisation (EXC) des 2 évals
|
# Neutralisation (EXC) des 2 évals
|
||||||
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=scu.NOTES_NEUTRALISE) # EXC
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=scu.NOTES_NEUTRALISE) # EXC
|
||||||
@ -196,15 +191,14 @@ def test_notes_modules(test_client):
|
|||||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||||
sem["formsemestre_id"], etud["etudid"]
|
sem["formsemestre_id"], etud["etudid"]
|
||||||
)
|
)
|
||||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == "-"
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == "~"
|
||||||
check_nt(
|
check_nt(
|
||||||
etudid,
|
etudid,
|
||||||
sem["formsemestre_id"],
|
sem["formsemestre_id"],
|
||||||
ue_id,
|
ue_id,
|
||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy="NA",
|
expected_mod_moy=np.nan,
|
||||||
expected_moy_ue=0.0,
|
expected_moy_ue=np.nan,
|
||||||
expected_sum_coefs_ue=0.0,
|
|
||||||
)
|
)
|
||||||
# Attente (ATT) sur les 2 evals
|
# Attente (ATT) sur les 2 evals
|
||||||
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=scu.NOTES_ATTENTE) # ATT
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=scu.NOTES_ATTENTE) # ATT
|
||||||
@ -212,15 +206,14 @@ def test_notes_modules(test_client):
|
|||||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||||
sem["formsemestre_id"], etud["etudid"]
|
sem["formsemestre_id"], etud["etudid"]
|
||||||
)
|
)
|
||||||
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == "-"
|
assert b["ues"][0]["modules"][0]["mod_moy_txt"] == "~"
|
||||||
check_nt(
|
check_nt(
|
||||||
etudid,
|
etudid,
|
||||||
sem["formsemestre_id"],
|
sem["formsemestre_id"],
|
||||||
ue_id,
|
ue_id,
|
||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy="NA",
|
expected_mod_moy=np.nan,
|
||||||
expected_moy_ue=0.0,
|
expected_moy_ue=np.nan,
|
||||||
expected_sum_coefs_ue=0.0,
|
|
||||||
)
|
)
|
||||||
# Non inscrit
|
# Non inscrit
|
||||||
# - désinscrit notre étudiant:
|
# - désinscrit notre étudiant:
|
||||||
@ -243,8 +236,7 @@ def test_notes_modules(test_client):
|
|||||||
ue_id,
|
ue_id,
|
||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy="NI",
|
expected_mod_moy="NI",
|
||||||
expected_moy_ue=0.0,
|
expected_moy_ue=np.nan,
|
||||||
expected_sum_coefs_ue=0.0,
|
|
||||||
)
|
)
|
||||||
# --- Maintenant avec 2 modules dans l'UE
|
# --- Maintenant avec 2 modules dans l'UE
|
||||||
coef_mod_2 = 2.1
|
coef_mod_2 = 2.1
|
||||||
@ -260,17 +252,22 @@ def test_notes_modules(test_client):
|
|||||||
module_id=module_id2,
|
module_id=module_id2,
|
||||||
formsemestre_id=formsemestre_id,
|
formsemestre_id=formsemestre_id,
|
||||||
)
|
)
|
||||||
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
|
# Pour prendre en compte l'ajout au vol d'un moduleimpl:
|
||||||
|
del formsemestre.modimpls_sorted
|
||||||
|
|
||||||
# Re-inscription au premier module de l'UE
|
# Re-inscription au premier module de l'UE
|
||||||
sco_moduleimpl.do_moduleimpl_inscription_create(
|
sco_moduleimpl.do_moduleimpl_inscription_create(
|
||||||
{"etudid": etudid, "moduleimpl_id": moduleimpl_id},
|
{"etudid": etudid, "moduleimpl_id": moduleimpl_id},
|
||||||
formsemestre_id=formsemestre_id,
|
formsemestre_id=formsemestre_id,
|
||||||
)
|
)
|
||||||
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=12.5)
|
_, _, _ = G.create_note(evaluation=e1, etud=etud, note=12.5)
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
|
mod_stats = nt.get_mod_stats(moduleimpl_id)
|
||||||
|
assert mod_stats["nb_missing"] == 0
|
||||||
|
assert mod_stats["nb_notes"] == 2
|
||||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
||||||
assert ue_status["nb_missing"] == 1 # 1 même si etud non inscrit à l'autre module
|
|
||||||
assert ue_status["nb_notes"] == 1
|
|
||||||
assert not ue_status["was_capitalized"]
|
assert not ue_status["was_capitalized"]
|
||||||
# Inscription au deuxième module de l'UE
|
# Inscription au deuxième module de l'UE
|
||||||
sco_moduleimpl.do_moduleimpl_inscription_create(
|
sco_moduleimpl.do_moduleimpl_inscription_create(
|
||||||
@ -284,8 +281,7 @@ def test_notes_modules(test_client):
|
|||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
||||||
assert ue_status["nb_missing"] == 1 # mi2 n'a pas encore de note
|
|
||||||
assert ue_status["nb_notes"] == 1
|
|
||||||
# Note dans module 2:
|
# Note dans module 2:
|
||||||
e_m2 = G.create_evaluation(
|
e_m2 = G.create_evaluation(
|
||||||
moduleimpl_id=moduleimpl_id2,
|
moduleimpl_id=moduleimpl_id2,
|
||||||
@ -297,8 +293,6 @@ def test_notes_modules(test_client):
|
|||||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
||||||
assert ue_status["nb_missing"] == 1 # manque une note
|
|
||||||
assert ue_status["nb_notes"] == 1
|
|
||||||
|
|
||||||
# Moyenne d'UE si l'un des modules est EXC ("NA")
|
# Moyenne d'UE si l'un des modules est EXC ("NA")
|
||||||
# 2 modules, notes EXC dans le premier, note valide n dans le second
|
# 2 modules, notes EXC dans le premier, note valide n dans le second
|
||||||
@ -309,6 +303,7 @@ def test_notes_modules(test_client):
|
|||||||
_, _, _ = G.create_note(evaluation=e1, etud=etuds[1], note=11.0)
|
_, _, _ = G.create_note(evaluation=e1, etud=etuds[1], note=11.0)
|
||||||
_, _, _ = G.create_note(evaluation=e2, etud=etuds[1], note=11.0)
|
_, _, _ = G.create_note(evaluation=e2, etud=etuds[1], note=11.0)
|
||||||
_, _, _ = G.create_note(evaluation=e_m2, etud=etuds[1], note=11.0)
|
_, _, _ = G.create_note(evaluation=e_m2, etud=etuds[1], note=11.0)
|
||||||
|
|
||||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||||
sem["formsemestre_id"], etud["etudid"]
|
sem["formsemestre_id"], etud["etudid"]
|
||||||
)
|
)
|
||||||
@ -384,7 +379,7 @@ def test_notes_modules_att_dem(test_client):
|
|||||||
)
|
)
|
||||||
assert b["etud_etat"] == "D"
|
assert b["etud_etat"] == "D"
|
||||||
assert b["nb_demissions"] == 1
|
assert b["nb_demissions"] == 1
|
||||||
assert b["ues"] == [] # inscrit à aucune UE !
|
|
||||||
# bulletin de l'étudiant non demissionnaire:
|
# bulletin de l'étudiant non demissionnaire:
|
||||||
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
b = sco_bulletins.formsemestre_bulletinetud_dict(
|
||||||
sem["formsemestre_id"], etuds[1]["etudid"]
|
sem["formsemestre_id"], etuds[1]["etudid"]
|
||||||
@ -397,14 +392,19 @@ def test_notes_modules_att_dem(test_client):
|
|||||||
sem["formsemestre_id"],
|
sem["formsemestre_id"],
|
||||||
ue_id,
|
ue_id,
|
||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy="NA",
|
expected_mod_moy=np.nan,
|
||||||
expected_moy_ue=0.0,
|
expected_moy_ue=np.nan,
|
||||||
expected_sum_coefs_ue=0.0,
|
|
||||||
)
|
)
|
||||||
note_e1 = nt.get_etud_eval_note(etuds[1]["etudid"], e1["evaluation_id"])
|
note_e1 = nt.modimpls_results[moduleimpl_id].evals_notes[e1["evaluation_id"]][
|
||||||
assert note_e1["value"] == scu.NOTES_ATTENTE
|
etuds[1]["etudid"]
|
||||||
note_e1 = nt.get_etud_eval_note(etuds[0]["etudid"], e1["evaluation_id"])
|
]
|
||||||
assert note_e1["value"] == scu.NOTES_ATTENTE # XXXX un peu contestable
|
assert note_e1 == scu.NOTES_ATTENTE
|
||||||
|
|
||||||
|
note_e1 = nt.modimpls_results[moduleimpl_id].evals_notes[e1["evaluation_id"]][
|
||||||
|
etuds[0]["etudid"]
|
||||||
|
]
|
||||||
|
assert note_e1 == scu.NOTES_ATTENTE # XXXX un peu contestable
|
||||||
|
|
||||||
# Saisie note ABS pour le deuxième etud
|
# Saisie note ABS pour le deuxième etud
|
||||||
_, _, _ = G.create_note(evaluation=e1, etud=etuds[1], note=None) # ABS
|
_, _, _ = G.create_note(evaluation=e1, etud=etuds[1], note=None) # ABS
|
||||||
nt = check_nt(
|
nt = check_nt(
|
||||||
@ -414,7 +414,8 @@ def test_notes_modules_att_dem(test_client):
|
|||||||
moduleimpl_id,
|
moduleimpl_id,
|
||||||
expected_mod_moy=0.0,
|
expected_mod_moy=0.0,
|
||||||
expected_moy_ue=0.0,
|
expected_moy_ue=0.0,
|
||||||
expected_sum_coefs_ue=coef_mod_1,
|
|
||||||
)
|
)
|
||||||
note_e1 = nt.get_etud_eval_note(etuds[1]["etudid"], e1["evaluation_id"])
|
note_e1 = nt.modimpls_results[moduleimpl_id].evals_notes[e1["evaluation_id"]][
|
||||||
assert note_e1["value"] is None
|
etuds[1]["etudid"]
|
||||||
|
]
|
||||||
|
assert note_e1 == scu.NOTES_ABSENCE
|
||||||
|
@ -4,12 +4,8 @@
|
|||||||
|
|
||||||
Utiliser comme:
|
Utiliser comme:
|
||||||
pytest tests/unit/test_periode.py
|
pytest tests/unit/test_periode.py
|
||||||
"""
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
from app.scodoc.sco_formsemestre import get_periode, sem_in_semestre_scolaire
|
Calcule la session associée à un formsemestre sous la forme (année, période)
|
||||||
|
|
||||||
""" Calcule la session associée à un formsemestre sous la forme (année, période)
|
|
||||||
année: première année de l'année scolaire
|
année: première année de l'année scolaire
|
||||||
période = 1 (première période de l'année scolaire) ou 2 (deuxième période de l'année scolaire)
|
période = 1 (première période de l'année scolaire) ou 2 (deuxième période de l'année scolaire)
|
||||||
les quatre derniers paramètres forment les dates pivots pour l'année (1er août par défaut)
|
les quatre derniers paramètres forment les dates pivots pour l'année (1er août par défaut)
|
||||||
@ -25,67 +21,88 @@ Début FormSemestre pivot_année pivot_periode Résultat
|
|||||||
30/07/2022 ( 1, 1) ( 1, 8) (2022,1) # antipodes
|
30/07/2022 ( 1, 1) ( 1, 8) (2022,1) # antipodes
|
||||||
02/08/2022 ( 1, 1) ( 1, 8) (2022,2) # antipodes
|
02/08/2022 ( 1, 1) ( 1, 8) (2022,2) # antipodes
|
||||||
30/12/2022 ( 1, 1) ( 1, 8) (2022,2) # antipodes
|
30/12/2022 ( 1, 1) ( 1, 8) (2022,2) # antipodes
|
||||||
01/01/2022 ( 3, 1) ( 1, 8) (2021,2) # antipodes l'année scolaire démarre le 3 janvier
|
01/01/2022 ( 3, 1) ( 1, 8) (2021,2) # antipodes l'année sco démarre le 3 janvier
|
||||||
10/01/2024 ( 1, 8) ( 1, 2) (2023,2) # pivot période < pivot année
|
10/01/2024 ( 1, 8) ( 1, 2) (2023,2) # pivot période < pivot année
|
||||||
01/06/2024 ( 1, 8) ( 1, 2) (2023,2) # pivot période < pivot année
|
01/06/2024 ( 1, 8) ( 1, 2) (2023,2) # pivot période < pivot année
|
||||||
20/09/2024 ( 1, 8) ( 1, 2) (2024,1) # pivot période < pivot année
|
20/09/2024 ( 1, 8) ( 1, 2) (2024,1) # pivot période < pivot année
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from app.models import FormSemestre
|
||||||
|
from app.scodoc.sco_formsemestre import sem_in_semestre_scolaire
|
||||||
|
|
||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
# with default
|
# with default
|
||||||
assert (2021, 2) == get_periode(datetime.datetime(2022, 1, 1))
|
assert (2021, 2) == FormSemestre.comp_periode(datetime.datetime(2022, 1, 1))
|
||||||
assert (2021, 2) == get_periode(datetime.datetime(2022, 1, 1), 1, 8, 1, 12)
|
assert (2021, 2) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2022, 1, 1), 8, 12, 1, 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_automne_nord():
|
def test_automne_nord():
|
||||||
assert (2022, 1) == get_periode(datetime.datetime(2022, 9, 1))
|
assert (2022, 1) == FormSemestre.comp_periode(datetime.datetime(2022, 9, 1))
|
||||||
|
|
||||||
|
|
||||||
def test_noel_nord():
|
def test_noel_nord():
|
||||||
assert (2022, 2) == get_periode(datetime.datetime(2022, 12, 15))
|
assert (2022, 2) == FormSemestre.comp_periode(datetime.datetime(2022, 12, 15))
|
||||||
|
|
||||||
|
|
||||||
def test_étét_nord():
|
def test_ete_nord():
|
||||||
assert (2021, 2) == get_periode(datetime.datetime(2022, 7, 30))
|
assert (2021, 2) == FormSemestre.comp_periode(datetime.datetime(2022, 7, 30))
|
||||||
|
|
||||||
|
|
||||||
def test_printemps_sud():
|
def test_printemps_sud():
|
||||||
assert (2022, 1) == get_periode(datetime.datetime(2022, 1, 1), 1, 1, 1, 8)
|
assert (2022, 1) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2022, 1, 1), 1, 1, 1, 8
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_automne_sud():
|
def test_automne_sud():
|
||||||
assert (2022, 2) == get_periode(datetime.datetime(2022, 8, 2), 1, 1, 1, 8)
|
assert (2022, 2) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2022, 8, 2), 1, 8, 1, 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_noel_sud():
|
def test_noel_sud():
|
||||||
assert (2022, 2) == get_periode(datetime.datetime(2022, 12, 30), 1, 1, 1, 8)
|
assert (2022, 2) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2022, 12, 30), 1, 8, 1, 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_été_sud():
|
def test_ete_sud():
|
||||||
assert (2022, 1) == get_periode(datetime.datetime(2022, 7, 30), 1, 1, 1, 8)
|
assert (2022, 1) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2022, 7, 30), 1, 8, 1, 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_nouvel_an_sud():
|
def test_nouvel_an_sud():
|
||||||
assert (2021, 2) == get_periode(datetime.datetime(2022, 1, 1), 3, 1, 1, 8)
|
assert (2021, 2) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2022, 1, 1), 3, 8, 1, 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_nouvel_an_special_pp_before_pa():
|
def test_nouvel_an_special_pp_before_pa():
|
||||||
assert (2023, 1) == get_periode(datetime.datetime(2024, 1, 10), 1, 8, 1, 2)
|
assert (2023, 1) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2024, 1, 10), 8, 2, 1, 1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_nouvel_été_pp_before_pa():
|
def test_nouvel_ete_pp_before_pa():
|
||||||
assert (2023, 2) == get_periode(datetime.datetime(2024, 6, 1), 1, 8, 1, 2)
|
assert (2023, 2) == FormSemestre.comp_periode(
|
||||||
|
datetime.datetime(2024, 6, 1), 1, 8, 1, 2
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_automne_special_pp_before_pa():
|
def test_automne_special_pp_before_pa():
|
||||||
assert (2024, 1) == get_periode(datetime.datetime(2024, 9, 20), 1, 8, 1, 2)
|
assert (2024, 1) == FormSemestre.comp_periode(datetime.datetime(2024, 9, 20), 8, 2)
|
||||||
|
|
||||||
|
|
||||||
sem_automne = {"date_debut_iso": "2022-09-24"}
|
sem_automne = {"date_debut_iso": "2022-09-24"}
|
||||||
sem_nouvel_an = {"date_debut_iso": "2023-01-01"}
|
sem_nouvel_an = {"date_debut_iso": "2023-01-01"}
|
||||||
sem_printemps = {"date_debut_iso": "2023-03-14"}
|
sem_printemps = {"date_debut_iso": "2023-03-14"}
|
||||||
sem_été = {"date_debut_iso": "2023-07-11"}
|
sem_ete = {"date_debut_iso": "2023-07-11"}
|
||||||
sem_next_year = {"date_debut_iso": "2023-08-16"}
|
sem_next_year = {"date_debut_iso": "2023-08-16"}
|
||||||
sem_prev_year = {"date_debut_iso": "2022-07-31"}
|
sem_prev_year = {"date_debut_iso": "2022-07-31"}
|
||||||
|
|
||||||
@ -94,7 +111,7 @@ def test_sem_in_periode1_default():
|
|||||||
assert True == sem_in_semestre_scolaire(sem_automne, 2022, 1)
|
assert True == sem_in_semestre_scolaire(sem_automne, 2022, 1)
|
||||||
assert False == sem_in_semestre_scolaire(sem_nouvel_an, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_nouvel_an, 2022, 1)
|
||||||
assert False == sem_in_semestre_scolaire(sem_printemps, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_printemps, 2022, 1)
|
||||||
assert False == sem_in_semestre_scolaire(sem_été, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_ete, 2022, 1)
|
||||||
assert False == sem_in_semestre_scolaire(sem_next_year, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_next_year, 2022, 1)
|
||||||
assert False == sem_in_semestre_scolaire(sem_prev_year, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_prev_year, 2022, 1)
|
||||||
|
|
||||||
@ -103,7 +120,7 @@ def test_sem_in_periode2_default():
|
|||||||
assert False == sem_in_semestre_scolaire(sem_automne, 2022, 2)
|
assert False == sem_in_semestre_scolaire(sem_automne, 2022, 2)
|
||||||
assert True == sem_in_semestre_scolaire(sem_nouvel_an, 2022, 2)
|
assert True == sem_in_semestre_scolaire(sem_nouvel_an, 2022, 2)
|
||||||
assert True == sem_in_semestre_scolaire(sem_printemps, 2022, 2)
|
assert True == sem_in_semestre_scolaire(sem_printemps, 2022, 2)
|
||||||
assert True == sem_in_semestre_scolaire(sem_été, 2022, 2)
|
assert True == sem_in_semestre_scolaire(sem_ete, 2022, 2)
|
||||||
assert False == sem_in_semestre_scolaire(sem_next_year, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_next_year, 2022, 1)
|
||||||
assert False == sem_in_semestre_scolaire(sem_prev_year, 2022, 1)
|
assert False == sem_in_semestre_scolaire(sem_prev_year, 2022, 1)
|
||||||
|
|
||||||
@ -112,6 +129,6 @@ def test_sem_in_annee_default():
|
|||||||
assert True == sem_in_semestre_scolaire(sem_automne, 2022, 0)
|
assert True == sem_in_semestre_scolaire(sem_automne, 2022, 0)
|
||||||
assert True == sem_in_semestre_scolaire(sem_nouvel_an, 2022)
|
assert True == sem_in_semestre_scolaire(sem_nouvel_an, 2022)
|
||||||
assert True == sem_in_semestre_scolaire(sem_printemps, 2022, 0)
|
assert True == sem_in_semestre_scolaire(sem_printemps, 2022, 0)
|
||||||
assert True == sem_in_semestre_scolaire(sem_été, 2022, 0)
|
assert True == sem_in_semestre_scolaire(sem_ete, 2022, 0)
|
||||||
assert False == sem_in_semestre_scolaire(sem_next_year, 2022)
|
assert False == sem_in_semestre_scolaire(sem_next_year, 2022)
|
||||||
assert False == sem_in_semestre_scolaire(sem_prev_year, 2022, 0)
|
assert False == sem_in_semestre_scolaire(sem_prev_year, 2022, 0)
|
||||||
|
@ -13,8 +13,7 @@ Au besoin, créer un base de test neuve:
|
|||||||
"""
|
"""
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from flask import g
|
from app.models import FormSemestreInscription, Identite
|
||||||
from app.models.formsemestre import FormSemestreInscription
|
|
||||||
|
|
||||||
from config import TestConfig
|
from config import TestConfig
|
||||||
from tests.unit import sco_fake_gen
|
from tests.unit import sco_fake_gen
|
||||||
@ -88,7 +87,7 @@ def run_sco_basic(verbose=False):
|
|||||||
G.inscrit_etudiant(formsemestre_id, etud)
|
G.inscrit_etudiant(formsemestre_id, etud)
|
||||||
# Vérification incription semestre:
|
# Vérification incription semestre:
|
||||||
q = FormSemestreInscription.query.filter_by(
|
q = FormSemestreInscription.query.filter_by(
|
||||||
etudid=etuds[0].id, formsemestre_id=formsemestre_id
|
etudid=etuds[0]["id"], formsemestre_id=formsemestre_id
|
||||||
)
|
)
|
||||||
assert q.count() == 1
|
assert q.count() == 1
|
||||||
ins = q.first()
|
ins = q.first()
|
||||||
@ -230,7 +229,8 @@ def run_sco_basic(verbose=False):
|
|||||||
|
|
||||||
# ---- Suppression étudiant, vérification inscription
|
# ---- Suppression étudiant, vérification inscription
|
||||||
# (permet de tester les cascades)
|
# (permet de tester les cascades)
|
||||||
etud = etuds[0]
|
etud = Identite.query.get(etuds[0]["id"])
|
||||||
|
assert etud is not None
|
||||||
etudid = etud.id
|
etudid = etud.id
|
||||||
db.session.delete(etud)
|
db.session.delete(etud)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user