From 7eb41fb2eb222532d40ce5bf36caf06450d60be9 Mon Sep 17 00:00:00 2001 From: Iziram Date: Fri, 1 Mar 2024 12:32:44 +0100 Subject: [PATCH] =?UTF-8?q?Assiduit=C3=A9=20:=20ajout=20test=20api=20manqu?= =?UTF-8?q?ant=20closes=20#689?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/justificatifs.py | 1 - tests/api/test_api_justificatifs.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/api/justificatifs.py b/app/api/justificatifs.py index 0a5f5350..b3528362 100644 --- a/app/api/justificatifs.py +++ b/app/api/justificatifs.py @@ -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 { diff --git a/tests/api/test_api_justificatifs.py b/tests/api/test_api_justificatifs.py index 5e73d2c7..5ae86528 100644 --- a/tests/api/test_api_justificatifs.py +++ b/tests/api/test_api_justificatifs.py @@ -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/""" + # 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/""" + # 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//create""" # -== Unique ==-