Assiduité : ajout test api manquant closes #689

This commit is contained in:
Iziram 2024-03-01 12:32:44 +01:00
parent a79ca4a17d
commit 7eb41fb2eb
2 changed files with 28 additions and 1 deletions

View File

@ -689,7 +689,6 @@ def justif_export(justif_id: int | None = None, filename: str | None = None):
@as_json
@permission_required(Permission.AbsChange)
def justif_remove(justif_id: int = None):
# XXX TODO pas de test unitaire
"""
Supression d'un fichier ou d'une archive
{

View File

@ -38,6 +38,8 @@ JUSTIFICATIFS_FIELDS = {
"external_data": dict,
}
DEPT_JUSTIFICATIFS_FIELDS = JUSTIFICATIFS_FIELDS | {"formsemestre": dict | None}
CREATE_FIELD = {"justif_id": int, "couverture": list}
BATCH_FIELD = {"errors": list, "success": list}
@ -169,6 +171,32 @@ def test_route_justificatifs(api_headers):
check_failure_get(f"/justificatifs/{FAUX}/query?", api_headers)
def test_route_justificatifs_formsemestre(api_headers):
"""test de la route /justificatifs/formsemestre/<int:formsemestre_id>"""
# Bon fonctionnement
data = GET(path="/justificatifs/formsemestre/1", headers=api_headers)
assert isinstance(data, list)
for just in data:
check_fields(just, JUSTIFICATIFS_FIELDS)
# Mauvais fonctionnement
check_failure_get(path="/justificatifs/formsemestre/42069", headers=api_headers)
def test_justificatifs_dept(api_headers):
"""test de la route /justificatifs/dept/<int:dept_id>"""
# Bon fonctionnement
data = GET(path="/justificatifs/dept/1", headers=api_headers)
assert isinstance(data, list)
for just in data:
check_fields(just, DEPT_JUSTIFICATIFS_FIELDS)
# Mauvais fonctionnement
check_failure_get(path="/justificatifs/dept/42069", headers=api_headers)
def test_route_create(api_admin_headers):
"""test de la route /justificatif/<justif_id:int>/create"""
# -== Unique ==-