From 85e7818843a118c68058951428c551cc7585e96e Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Mon, 27 Jun 2022 16:12:41 +0200 Subject: [PATCH] ajout des tests unitaires pour formsemestre_apo --- tests/api/test_api_formsemestre.py | 110 ++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 9 deletions(-) diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py index ed6d2791d..719dd3a4a 100644 --- a/tests/api/test_api_formsemestre.py +++ b/tests/api/test_api_formsemestre.py @@ -40,24 +40,116 @@ def test_formsemestre(api_headers): """ Route: /formsemestre/ """ + formsemestre_id = 1 r = requests.get( - API_URL + "/formsemestre/1", + f"{API_URL}/formsemestre/{formsemestre_id}", headers=api_headers, verify=CHECK_CERTIFICATE, ) assert r.status_code == 200 formsemestre = r.json() assert verify_fields(formsemestre, FSEM_FIELDS) + assert isinstance(formsemestre["block_moyennes"], bool) + assert isinstance(formsemestre["bul_bgcolor"], str) + assert isinstance(formsemestre["bul_hide_xml"], bool) + assert isinstance(formsemestre["date_debut_iso"], str) + assert isinstance(formsemestre["date_debut"], str) + assert isinstance(formsemestre["date_fin_iso"], str) + assert isinstance(formsemestre["date_fin"], str) + assert isinstance(formsemestre["dept_id"], int) + assert formsemestre["elt_annee_apo"] is None or isinstance( + formsemestre["elt_annee_apo"], str + ) + assert formsemestre["elt_sem_apo"] is None or isinstance( + formsemestre["elt_sem_apo"], str + ) + assert isinstance(formsemestre["ens_can_edit_eval"], bool) + assert isinstance(formsemestre["etat"], bool) + assert isinstance(formsemestre["formation_id"], int) + assert isinstance(formsemestre["formsemestre_id"], int) + assert isinstance(formsemestre["gestion_compensation"], bool) + assert isinstance(formsemestre["gestion_semestrielle"], bool) + assert isinstance(formsemestre["id"], int) + assert isinstance(formsemestre["modalite"], str) + assert isinstance(formsemestre["resp_can_change_ens"], bool) + assert isinstance(formsemestre["resp_can_edit"], bool) + assert isinstance(formsemestre["responsables"], list) + assert formsemestre["scodoc7_id"] is None or isinstance( + formsemestre["scodoc7_id"], int + ) + assert isinstance(formsemestre["semestre_id"], int) + assert isinstance(formsemestre["titre_formation"], str) + assert isinstance(formsemestre["titre_num"], str) + assert isinstance(formsemestre["titre"], str) + + ### ERROR ### + formsemestre_id_inexistant = 165456165165136513510351 + r = requests.get( + f"{API_URL}/formsemestre/{formsemestre_id_inexistant}", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r.status_code == 404 -# XXX TODO ajouter une etape_apo dans la base de test -# def test_formsemestre_apo(api_headers): -# r = requests.get( -# API_URL + "/formation/apo/", -# headers=api_headers, -# verify=CHECK_CERTIFICATE, -# ) -# assert r.status_code == 200 +def test_formsemestre_apo(api_headers): + """ + Route: /formsemestre/apo/ + """ + etape_apo = "A1" + r = requests.get( + f"{API_URL}/formsemestre/apo/{etape_apo}", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r.status_code == 200 + list_formsemestre = r.json() + assert isinstance(list_formsemestre, list) + + for formsemestre in list_formsemestre: + assert isinstance(formsemestre, dict) + assert verify_fields(formsemestre, FSEM_FIELDS) + assert isinstance(formsemestre["block_moyennes"], bool) + assert isinstance(formsemestre["bul_bgcolor"], str) + assert isinstance(formsemestre["bul_hide_xml"], bool) + assert isinstance(formsemestre["date_debut_iso"], str) + assert isinstance(formsemestre["date_debut"], str) + assert isinstance(formsemestre["date_fin_iso"], str) + assert isinstance(formsemestre["date_fin"], str) + assert isinstance(formsemestre["dept_id"], int) + assert formsemestre["elt_annee_apo"] is None or isinstance( + formsemestre["elt_annee_apo"], str + ) + assert formsemestre["elt_sem_apo"] is None or isinstance( + formsemestre["elt_sem_apo"], str + ) + assert isinstance(formsemestre["ens_can_edit_eval"], bool) + assert isinstance(formsemestre["etat"], bool) + assert isinstance(formsemestre["formation_id"], int) + assert isinstance(formsemestre["formsemestre_id"], int) + assert isinstance(formsemestre["gestion_compensation"], bool) + assert isinstance(formsemestre["gestion_semestrielle"], bool) + assert isinstance(formsemestre["id"], int) + assert isinstance(formsemestre["modalite"], str) + assert isinstance(formsemestre["resp_can_change_ens"], bool) + assert isinstance(formsemestre["resp_can_edit"], bool) + assert isinstance(formsemestre["responsables"], list) + assert formsemestre["scodoc7_id"] is None or isinstance( + formsemestre["scodoc7_id"], int + ) + assert isinstance(formsemestre["semestre_id"], int) + assert isinstance(formsemestre["titre_formation"], str) + assert isinstance(formsemestre["titre_num"], str) + assert isinstance(formsemestre["titre"], str) + + ### ERROR ### + etape_apo_inexistante = "aoefiaozidaoẑidjnoaiznjd" + r = requests.get( + f"{API_URL}/formsemestre/apo/{etape_apo_inexistante}", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r.status_code == 404 def test_bulletins(api_headers):