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(
|
||||
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
|
||||
"""
|
||||
@ -181,29 +181,32 @@ def test_etat_evals(
|
||||
|
||||
assert len(etat_evals) == 3
|
||||
|
||||
ue = etat_evals[0]
|
||||
assert len(ue) == 3
|
||||
assert isinstance(ue["id"], int)
|
||||
assert isinstance(ue["titre"], str)
|
||||
assert isinstance(ue["evaluations"], list)
|
||||
for ue in etat_evals.values():
|
||||
for module in ue:
|
||||
assert isinstance(module["id"], int)
|
||||
assert isinstance(module["titre"], str)
|
||||
assert isinstance(module["evaluations"], list)
|
||||
|
||||
eval = ue["evaluations"][0]
|
||||
assert len(eval) == 11
|
||||
for eval in module["evaluations"]:
|
||||
assert verify_fields(eval, EVAL_FIELDS)
|
||||
assert isinstance(eval["id"], int)
|
||||
assert eval["description"] is None or isinstance(eval["description"], str)
|
||||
assert isinstance(eval["datetime_epreuve"], str)
|
||||
assert eval["description"] is None or isinstance(
|
||||
eval["description"], str
|
||||
)
|
||||
assert eval["datetime_epreuve"] is None or isinstance(
|
||||
eval["datetime_epreuve"], str
|
||||
)
|
||||
assert isinstance(eval["heure_fin"], str)
|
||||
assert isinstance(eval["coef"], float)
|
||||
assert isinstance(eval["coefficient"], float)
|
||||
assert isinstance(eval["comptee"], str)
|
||||
assert isinstance(eval["inscrits"], int)
|
||||
assert isinstance(eval["manquantes"], int)
|
||||
assert isinstance(eval["ABS"], int)
|
||||
assert isinstance(eval["ATT"], int)
|
||||
assert isinstance(eval["EXC"], int)
|
||||
assert isinstance(eval["saisie_notes"], list)
|
||||
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
|
||||
for id in list_eval_id:
|
||||
if list_eval_id.count(id) > 1:
|
||||
@ -212,117 +215,63 @@ def test_etat_evals(
|
||||
|
||||
saisie_notes = eval["saisie_notes"]
|
||||
assert verify_fields(saisie_notes, SAISIE_NOTES_FIELDS)
|
||||
assert isinstance(eval["saisie_notes"]["datetime_debut"], str)
|
||||
assert isinstance(eval["saisie_notes"]["datetime_fin"], str)
|
||||
assert isinstance(eval["saisie_notes"]["datetime_mediane"], str)
|
||||
assert (
|
||||
eval["saisie_notes"]["datetime_fin"] > eval["saisie_notes"]["datetime_mediane"]
|
||||
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
|
||||
eval["saisie_notes"]["datetime_debut"], str
|
||||
)
|
||||
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
|
||||
eval["saisie_notes"]["datetime_fin"], str
|
||||
)
|
||||
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
|
||||
eval["saisie_notes"]["datetime_mediane"], str
|
||||
)
|
||||
|
||||
if (
|
||||
eval["saisie_notes"]["datetime_fin"] is not None
|
||||
and eval["saisie_notes"]["datetime_mediane"] is not None
|
||||
and eval["saisie_notes"]["datetime_debut"] is not None
|
||||
):
|
||||
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_fin"] > eval["saisie_notes"]["datetime_debut"]
|
||||
assert (
|
||||
eval["saisie_notes"]["datetime_mediane"]
|
||||
> eval["saisie_notes"]["datetime_debut"]
|
||||
)
|
||||
|
||||
ue2 = etat_evals[1]
|
||||
assert len(ue2) == 3
|
||||
assert isinstance(ue2["id"], int)
|
||||
assert isinstance(ue2["titre"], str)
|
||||
assert isinstance(ue2["evaluations"], list)
|
||||
list_id_ue1 = []
|
||||
list_titre_ue1 = []
|
||||
|
||||
eval2 = ue2["evaluations"][0]
|
||||
assert len(eval2) == 11
|
||||
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_id_ue2 = []
|
||||
list_titre_ue2 = []
|
||||
|
||||
list_eval_id2 = [e["id"] for e in ue["evaluations"]]
|
||||
all_unique2 = True
|
||||
for id in list_eval_id2:
|
||||
if list_eval_id2.count(id) > 1:
|
||||
all_unique2 = False
|
||||
assert all_unique2 is True
|
||||
list_id_ue3 = []
|
||||
list_titre_ue3 = []
|
||||
i = 0
|
||||
for ue in etat_evals.values():
|
||||
i += 1
|
||||
for module in ue:
|
||||
if i == 1:
|
||||
list_id_ue1.append(module["id"])
|
||||
list_titre_ue1.append(module["id"])
|
||||
elif i == 2:
|
||||
list_id_ue2.append(module["id"])
|
||||
list_titre_ue2.append(module["id"])
|
||||
elif i == 3:
|
||||
list_id_ue3.append(module["id"])
|
||||
list_titre_ue3.append(module["id"])
|
||||
|
||||
saisie_notes2 = eval2["saisie_notes"]
|
||||
assert verify_fields(saisie_notes2, SAISIE_NOTES_FIELDS)
|
||||
assert isinstance(eval2["saisie_notes"]["datetime_debut"], str)
|
||||
assert isinstance(eval2["saisie_notes"]["datetime_fin"], str)
|
||||
assert isinstance(eval2["saisie_notes"]["datetime_mediane"], str)
|
||||
assert (
|
||||
eval2["saisie_notes"]["datetime_fin"]
|
||||
> eval2["saisie_notes"]["datetime_mediane"]
|
||||
)
|
||||
assert (
|
||||
eval2["saisie_notes"]["datetime_fin"] > eval2["saisie_notes"]["datetime_debut"]
|
||||
)
|
||||
assert (
|
||||
eval2["saisie_notes"]["datetime_mediane"]
|
||||
> eval2["saisie_notes"]["datetime_debut"]
|
||||
)
|
||||
assert list_id_ue1 != list_id_ue2
|
||||
assert list_id_ue1 != list_titre_ue3
|
||||
assert list_id_ue2 != list_titre_ue3
|
||||
|
||||
ue3 = etat_evals[2]
|
||||
assert len(ue3) == 3
|
||||
assert isinstance(ue3["id"], int)
|
||||
assert isinstance(ue3["titre"], str)
|
||||
assert isinstance(ue3["evaluations"], list)
|
||||
|
||||
eval3 = ue3["evaluations"][0]
|
||||
assert len(eval3) == 11
|
||||
assert verify_fields(eval3, EVAL_FIELDS)
|
||||
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"]
|
||||
assert list_titre_ue1 != list_titre_ue2
|
||||
assert list_titre_ue1 != list_titre_ue3
|
||||
assert list_titre_ue2 != list_titre_ue3
|
||||
|
||||
##### ERROR #####
|
||||
fake_eval_id = 153165161656849846516511321651651
|
||||
|
Loading…
Reference in New Issue
Block a user