From cacf437ef7a2ec80861b96a694aef1749dd53fd7 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Tue, 21 Jun 2022 15:59:12 +0200 Subject: [PATCH] ajout tests unitaires pour la route referentiel_competences --- tests/api/test_api_formations.py | 28 ++++++++++++++++++++++++++-- tests/api/tools_test_api.py | 15 +++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/api/test_api_formations.py b/tests/api/test_api_formations.py index b98a31e8..f2e4bfef 100644 --- a/tests/api/test_api_formations.py +++ b/tests/api/test_api_formations.py @@ -28,6 +28,7 @@ from tests.api.tools_test_api import ( FORMATION_EXPORT_UE_MATIERE_MODULE_FIELDS, FORMATION_EXPORT_UE_MATIERE_MODULE_COEF_FIELDS, MODULE_FIELDS, + REF_COMP_FIELDS, ) from tests.api.tools_test_api import FORMATION_FIELDS, MODIMPL_FIELDS @@ -263,9 +264,32 @@ def test_referentiel_competences(api_headers): Route: "/formation//referentiel_competences", """ r = requests.get( - API_URL + "/formation/1/referentiel_competences", + f"{API_URL}/formation/1/referentiel_competences", headers=api_headers, verify=CHECK_CERTIFICATE, ) assert r.status_code == 200 - # XXX TODO ajouter un referentiel competence dans la base de test + + ref_comp = r.json() + assert verify_fields(ref_comp, REF_COMP_FIELDS) is True + assert isinstance(ref_comp["dept_id"], int) + assert isinstance(ref_comp["annexe"], str) + assert isinstance(ref_comp["specialite"], str) + assert isinstance(ref_comp["specialite_long"], str) + assert isinstance(ref_comp["type_structure"], str) + assert isinstance(ref_comp["type_departement"], str) + assert isinstance(ref_comp["type_titre"], str) + assert isinstance(ref_comp["version_orebut"], str) + assert isinstance(ref_comp["scodoc_date_loaded"], str) + assert isinstance(ref_comp["scodoc_orig_filename"], str) + assert isinstance(ref_comp["competences"], dict) + assert isinstance(ref_comp["parcours"], dict) + + # ERROR + id_formation_inexistant = 1516476846861656351 + r_error = requests.get( + f"{API_URL}/formation/{id_formation_inexistant}/referentiel_competences", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r_error.status_code == 404 diff --git a/tests/api/tools_test_api.py b/tests/api/tools_test_api.py index a86b9ec1..7d5f03b6 100644 --- a/tests/api/tools_test_api.py +++ b/tests/api/tools_test_api.py @@ -508,6 +508,21 @@ EVAL_FIELDS = { SAISIE_NOTES_FIELDS = {"datetime_debut", "datetime_fin", "datetime_mediane"} +REF_COMP_FIELDS = { + "dept_id", + "annexe", + "specialite", + "specialite_long", + "type_structure", + "type_departement", + "type_titre", + "version_orebut", + "scodoc_date_loaded", + "scodoc_orig_filename", + "competences", + "parcours", +} + ABSENCES_FIELDS = { "jour", "matin",