forked from ScoDoc/ScoDoc
correction + factorisation des tests de etat_evals
This commit is contained in:
parent
39b913adfd
commit
55df675687
@ -166,7 +166,7 @@ def test_formsemestre_programme(api_headers):
|
|||||||
|
|
||||||
def test_etat_evals(
|
def test_etat_evals(
|
||||||
api_headers,
|
api_headers,
|
||||||
): # XXX TODO Vérifier les champs, vérifier qu'il n'y a pas de répétition, vérifier que les dates de "saisie_notes" sont corrects (date_debut avant celle de fin mediane OK etc..)
|
):
|
||||||
"""
|
"""
|
||||||
Route : /formsemestre/<int:formsemestre_id>/etat_evals
|
Route : /formsemestre/<int:formsemestre_id>/etat_evals
|
||||||
"""
|
"""
|
||||||
@ -181,148 +181,97 @@ def test_etat_evals(
|
|||||||
|
|
||||||
assert len(etat_evals) == 3
|
assert len(etat_evals) == 3
|
||||||
|
|
||||||
ue = etat_evals[0]
|
for ue in etat_evals.values():
|
||||||
assert len(ue) == 3
|
for module in ue:
|
||||||
assert isinstance(ue["id"], int)
|
assert isinstance(module["id"], int)
|
||||||
assert isinstance(ue["titre"], str)
|
assert isinstance(module["titre"], str)
|
||||||
assert isinstance(ue["evaluations"], list)
|
assert isinstance(module["evaluations"], list)
|
||||||
|
|
||||||
eval = ue["evaluations"][0]
|
for eval in module["evaluations"]:
|
||||||
assert len(eval) == 11
|
assert verify_fields(eval, EVAL_FIELDS)
|
||||||
assert verify_fields(eval, EVAL_FIELDS)
|
assert isinstance(eval["id"], int)
|
||||||
assert isinstance(eval["id"], int)
|
assert eval["description"] is None or isinstance(
|
||||||
assert eval["description"] is None or isinstance(eval["description"], str)
|
eval["description"], str
|
||||||
assert isinstance(eval["datetime_epreuve"], str)
|
)
|
||||||
assert isinstance(eval["heure_fin"], str)
|
assert eval["datetime_epreuve"] is None or isinstance(
|
||||||
assert isinstance(eval["coef"], float)
|
eval["datetime_epreuve"], str
|
||||||
assert isinstance(eval["comptee"], str)
|
)
|
||||||
assert isinstance(eval["inscrits"], int)
|
assert isinstance(eval["heure_fin"], str)
|
||||||
assert isinstance(eval["manquantes"], int)
|
assert isinstance(eval["coefficient"], float)
|
||||||
assert isinstance(eval["ABS"], int)
|
assert isinstance(eval["comptee"], str)
|
||||||
assert isinstance(eval["ATT"], int)
|
assert isinstance(eval["inscrits"], int)
|
||||||
assert isinstance(eval["EXC"], int)
|
assert isinstance(eval["manquantes"], int)
|
||||||
assert isinstance(eval["saisie_notes"], list)
|
assert isinstance(eval["ABS"], int)
|
||||||
|
assert isinstance(eval["ATT"], int)
|
||||||
|
assert isinstance(eval["EXC"], int)
|
||||||
|
assert isinstance(eval["saisie_notes"], dict)
|
||||||
|
|
||||||
list_eval_id = [e["id"] for e in ue["evaluations"]]
|
list_eval_id = [e["id"] for e in module["evaluations"]]
|
||||||
all_unique = True
|
all_unique = True
|
||||||
for id in list_eval_id:
|
for id in list_eval_id:
|
||||||
if list_eval_id.count(id) > 1:
|
if list_eval_id.count(id) > 1:
|
||||||
all_unique = False
|
all_unique = False
|
||||||
assert all_unique is True
|
assert all_unique is True
|
||||||
|
|
||||||
saisie_notes = eval["saisie_notes"]
|
saisie_notes = eval["saisie_notes"]
|
||||||
assert verify_fields(saisie_notes, SAISIE_NOTES_FIELDS)
|
assert verify_fields(saisie_notes, SAISIE_NOTES_FIELDS)
|
||||||
assert isinstance(eval["saisie_notes"]["datetime_debut"], str)
|
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
|
||||||
assert isinstance(eval["saisie_notes"]["datetime_fin"], str)
|
eval["saisie_notes"]["datetime_debut"], str
|
||||||
assert isinstance(eval["saisie_notes"]["datetime_mediane"], str)
|
)
|
||||||
assert (
|
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
|
||||||
eval["saisie_notes"]["datetime_fin"] > eval["saisie_notes"]["datetime_mediane"]
|
eval["saisie_notes"]["datetime_fin"], str
|
||||||
)
|
)
|
||||||
assert eval["saisie_notes"]["datetime_fin"] > eval["saisie_notes"]["datetime_debut"]
|
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
|
||||||
assert (
|
eval["saisie_notes"]["datetime_mediane"], str
|
||||||
eval["saisie_notes"]["datetime_mediane"]
|
)
|
||||||
> eval["saisie_notes"]["datetime_debut"]
|
|
||||||
)
|
|
||||||
|
|
||||||
ue2 = etat_evals[1]
|
if (
|
||||||
assert len(ue2) == 3
|
eval["saisie_notes"]["datetime_fin"] is not None
|
||||||
assert isinstance(ue2["id"], int)
|
and eval["saisie_notes"]["datetime_mediane"] is not None
|
||||||
assert isinstance(ue2["titre"], str)
|
and eval["saisie_notes"]["datetime_debut"] is not None
|
||||||
assert isinstance(ue2["evaluations"], list)
|
):
|
||||||
|
assert (
|
||||||
|
eval["saisie_notes"]["datetime_fin"]
|
||||||
|
> eval["saisie_notes"]["datetime_mediane"]
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
eval["saisie_notes"]["datetime_fin"]
|
||||||
|
> eval["saisie_notes"]["datetime_debut"]
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
eval["saisie_notes"]["datetime_mediane"]
|
||||||
|
> eval["saisie_notes"]["datetime_debut"]
|
||||||
|
)
|
||||||
|
|
||||||
eval2 = ue2["evaluations"][0]
|
list_id_ue1 = []
|
||||||
assert len(eval2) == 11
|
list_titre_ue1 = []
|
||||||
assert verify_fields(eval2, EVAL_FIELDS)
|
|
||||||
assert isinstance(eval2["id"], int)
|
|
||||||
assert eval2["description"] is None or isinstance(eval2["description"], str)
|
|
||||||
assert isinstance(eval2["datetime_epreuve"], str)
|
|
||||||
assert isinstance(eval2["heure_fin"], str)
|
|
||||||
assert isinstance(eval2["coef"], float)
|
|
||||||
assert isinstance(eval2["comptee"], str)
|
|
||||||
assert isinstance(eval2["inscrits"], int)
|
|
||||||
assert isinstance(eval2["manquantes"], int)
|
|
||||||
assert isinstance(eval2["ABS"], int)
|
|
||||||
assert isinstance(eval2["ATT"], int)
|
|
||||||
assert isinstance(eval2["EXC"], int)
|
|
||||||
assert isinstance(eval2["saisie_notes"], list)
|
|
||||||
|
|
||||||
list_eval_id2 = [e["id"] for e in ue["evaluations"]]
|
list_id_ue2 = []
|
||||||
all_unique2 = True
|
list_titre_ue2 = []
|
||||||
for id in list_eval_id2:
|
|
||||||
if list_eval_id2.count(id) > 1:
|
|
||||||
all_unique2 = False
|
|
||||||
assert all_unique2 is True
|
|
||||||
|
|
||||||
saisie_notes2 = eval2["saisie_notes"]
|
list_id_ue3 = []
|
||||||
assert verify_fields(saisie_notes2, SAISIE_NOTES_FIELDS)
|
list_titre_ue3 = []
|
||||||
assert isinstance(eval2["saisie_notes"]["datetime_debut"], str)
|
i = 0
|
||||||
assert isinstance(eval2["saisie_notes"]["datetime_fin"], str)
|
for ue in etat_evals.values():
|
||||||
assert isinstance(eval2["saisie_notes"]["datetime_mediane"], str)
|
i += 1
|
||||||
assert (
|
for module in ue:
|
||||||
eval2["saisie_notes"]["datetime_fin"]
|
if i == 1:
|
||||||
> eval2["saisie_notes"]["datetime_mediane"]
|
list_id_ue1.append(module["id"])
|
||||||
)
|
list_titre_ue1.append(module["id"])
|
||||||
assert (
|
elif i == 2:
|
||||||
eval2["saisie_notes"]["datetime_fin"] > eval2["saisie_notes"]["datetime_debut"]
|
list_id_ue2.append(module["id"])
|
||||||
)
|
list_titre_ue2.append(module["id"])
|
||||||
assert (
|
elif i == 3:
|
||||||
eval2["saisie_notes"]["datetime_mediane"]
|
list_id_ue3.append(module["id"])
|
||||||
> eval2["saisie_notes"]["datetime_debut"]
|
list_titre_ue3.append(module["id"])
|
||||||
)
|
|
||||||
|
|
||||||
ue3 = etat_evals[2]
|
assert list_id_ue1 != list_id_ue2
|
||||||
assert len(ue3) == 3
|
assert list_id_ue1 != list_titre_ue3
|
||||||
assert isinstance(ue3["id"], int)
|
assert list_id_ue2 != list_titre_ue3
|
||||||
assert isinstance(ue3["titre"], str)
|
|
||||||
assert isinstance(ue3["evaluations"], list)
|
|
||||||
|
|
||||||
eval3 = ue3["evaluations"][0]
|
assert list_titre_ue1 != list_titre_ue2
|
||||||
assert len(eval3) == 11
|
assert list_titre_ue1 != list_titre_ue3
|
||||||
assert verify_fields(eval3, EVAL_FIELDS)
|
assert list_titre_ue2 != list_titre_ue3
|
||||||
assert isinstance(eval3["id"], int)
|
|
||||||
assert eval3["description"] is None or isinstance(eval3["description"], str)
|
|
||||||
assert isinstance(eval3["datetime_epreuve"], str)
|
|
||||||
assert isinstance(eval3["heure_fin"], str)
|
|
||||||
assert isinstance(eval3["coef"], float)
|
|
||||||
assert isinstance(eval3["comptee"], str)
|
|
||||||
assert isinstance(eval3["inscrits"], int)
|
|
||||||
assert isinstance(eval3["manquantes"], int)
|
|
||||||
assert isinstance(eval3["ABS"], int)
|
|
||||||
assert isinstance(eval3["ATT"], int)
|
|
||||||
assert isinstance(eval3["EXC"], int)
|
|
||||||
assert isinstance(eval3["saisie_notes"], list)
|
|
||||||
|
|
||||||
list_eval_id3 = [e["id"] for e in ue["evaluations"]]
|
|
||||||
all_unique3 = True
|
|
||||||
for id in list_eval_id3:
|
|
||||||
if list_eval_id3.count(id) > 1:
|
|
||||||
all_unique3 = False
|
|
||||||
assert all_unique3 is True
|
|
||||||
|
|
||||||
saisie_notes3 = eval2["saisie_notes"]
|
|
||||||
assert verify_fields(saisie_notes3, SAISIE_NOTES_FIELDS)
|
|
||||||
assert isinstance(eval3["saisie_notes"]["datetime_debut"], str)
|
|
||||||
assert isinstance(eval3["saisie_notes"]["datetime_fin"], str)
|
|
||||||
assert isinstance(eval3["saisie_notes"]["datetime_mediane"], str)
|
|
||||||
assert (
|
|
||||||
eval3["saisie_notes"]["datetime_fin"]
|
|
||||||
> eval3["saisie_notes"]["datetime_mediane"]
|
|
||||||
)
|
|
||||||
assert (
|
|
||||||
eval3["saisie_notes"]["datetime_fin"] > eval3["saisie_notes"]["datetime_debut"]
|
|
||||||
)
|
|
||||||
assert (
|
|
||||||
eval3["saisie_notes"]["datetime_mediane"]
|
|
||||||
> eval3["saisie_notes"]["datetime_debut"]
|
|
||||||
)
|
|
||||||
|
|
||||||
assert ue["id"] != ue2["id"]
|
|
||||||
assert ue["id"] != ue3["id"]
|
|
||||||
assert ue2["id"] != ue3["id"]
|
|
||||||
|
|
||||||
assert ue["titre"] != ue2["titre"]
|
|
||||||
assert ue["titre"] != ue3["titre"]
|
|
||||||
assert ue2["titre"] != ue3["titre"]
|
|
||||||
|
|
||||||
##### ERROR #####
|
##### ERROR #####
|
||||||
fake_eval_id = 153165161656849846516511321651651
|
fake_eval_id = 153165161656849846516511321651651
|
||||||
|
Loading…
Reference in New Issue
Block a user