From aa5ec8e74c61c96108a20c1bf088c9b3b2498c7c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 31 Jan 2023 15:19:00 -0300 Subject: [PATCH] Fix test API formation et ajout d'un test (test_formation_export_with_ids) --- tests/api/test_api_formations.py | 20 +++++++++++++++++--- tests/api/tools_test_api.py | 14 ++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/api/test_api_formations.py b/tests/api/test_api_formations.py index 1869fc98..d4202f92 100644 --- a/tests/api/test_api_formations.py +++ b/tests/api/test_api_formations.py @@ -114,21 +114,18 @@ def test_formation_export(api_headers): assert r.status_code == 200 export_formation = r.json() assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True - assert isinstance(export_formation["dept_id"], int) assert isinstance(export_formation["acronyme"], str) assert isinstance(export_formation["titre_officiel"], str) assert isinstance(export_formation["formation_code"], str) assert export_formation["code_specialite"] is None or isinstance( export_formation["code_specialite"], str ) - assert isinstance(export_formation["id"], int) assert isinstance(export_formation["titre"], str) assert isinstance(export_formation["version"], int) assert isinstance(export_formation["type_parcours"], int) assert export_formation["referentiel_competence_id"] is None or isinstance( export_formation["referentiel_competence_id"], int ) - assert isinstance(export_formation["formation_id"], int) assert isinstance(export_formation["ue"], list) ues = export_formation["ue"] @@ -192,6 +189,23 @@ def test_formation_export(api_headers): assert r_error.status_code == 404 +def test_formation_export_with_ids(api_headers): + """ + Route: /formation//export_with_ids + """ + r = requests.get( + API_URL + "/formation/1/export_with_ids", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r.status_code == 200 + export_formation = r.json() + assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True + assert isinstance(export_formation["id"], int) + assert isinstance(export_formation["dept_id"], int) + assert isinstance(export_formation["formation_id"], int) + + def test_moduleimpl(api_headers): """ Route: /formation/moduleimpl/ diff --git a/tests/api/tools_test_api.py b/tests/api/tools_test_api.py index 7201031b..b277dd28 100644 --- a/tests/api/tools_test_api.py +++ b/tests/api/tools_test_api.py @@ -77,18 +77,16 @@ FORMATION_FIELDS = { } FORMATION_EXPORT_FIELDS = { - "dept_id", + # "dept_id" "id" "formation_id", pas présents sauf si export_with_ids "acronyme", - "titre_officiel", - "formation_code", "code_specialite", - "id", - "titre", - "version", - "type_parcours", + "formation_code", "referentiel_competence_id", - "formation_id", + "titre_officiel", + "titre", + "type_parcours", "ue", + "version", } FORMATION_EXPORT_UE_FIELDS = {