From b5e4017315c3ebe0682e603460b014822b966d27 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Wed, 4 May 2022 16:30:13 +0200 Subject: [PATCH] ajout tests unitaire pour evaluations et absences --- tests/api/test_api_absences.py | 68 +++++++++++++++++++++++-------- tests/api/test_api_evaluations.py | 30 ++++++++++++++ 2 files changed, 82 insertions(+), 16 deletions(-) diff --git a/tests/api/test_api_absences.py b/tests/api/test_api_absences.py index 0918af53..1e1fca64 100644 --- a/tests/api/test_api_absences.py +++ b/tests/api/test_api_absences.py @@ -19,62 +19,98 @@ Utilisation : import requests from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS +from tests.api.tools_test_api import verify_fields # absences def test_absences(): - r = requests.get( - SCODOC_URL + "/ScoDoc/api/absences/etudid/", - headers=HEADERS, - verify=CHECK_CERTIFICATE, - ) - assert r.status_code == 200 + + fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"] r = requests.get( - SCODOC_URL + "/ScoDoc/api/absences/nip/", + SCODOC_URL + "/ScoDoc/api/absences/etudid/1", headers=HEADERS, verify=CHECK_CERTIFICATE, ) + + abs = r.json()[0] + + fields_OK = verify_fields(abs, fields) + assert r.status_code == 200 + assert fields_OK is True r = requests.get( - SCODOC_URL + "/ScoDoc/api/absences/ine/", + SCODOC_URL + "/ScoDoc/api/absences/nip/1", headers=HEADERS, verify=CHECK_CERTIFICATE, ) + + abs = r.json()[0] + + fields_OK = verify_fields(abs, fields) assert r.status_code == 200 + assert fields_OK is True + + r = requests.get( + SCODOC_URL + "/ScoDoc/api/absences/ine/1", + headers=HEADERS, + verify=CHECK_CERTIFICATE, + ) + + abs = r.json()[0] + + fields_OK = verify_fields(abs, fields) + assert r.status_code == 200 + assert fields_OK is True # absences_justify def test_absences_justify(): + fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"] r = requests.get( SCODOC_URL + "/ScoDoc/api/absences/etudid/1/just", headers=HEADERS, verify=CHECK_CERTIFICATE, ) + + abs = r.json()[0] + + fields_OK = verify_fields(abs, fields) assert r.status_code == 200 + assert fields_OK is True r = requests.get( SCODOC_URL + "/ScoDoc/api/absences/nip/1/just", headers=HEADERS, verify=CHECK_CERTIFICATE, ) + + abs = r.json()[0] + + fields_OK = verify_fields(abs, fields) assert r.status_code == 200 + assert fields_OK is True r = requests.get( SCODOC_URL + "/ScoDoc/api/absences/ine/1/just", headers=HEADERS, verify=CHECK_CERTIFICATE, ) + + abs = r.json()[0] + + fields_OK = verify_fields(abs, fields) assert r.status_code == 200 + assert fields_OK is True # abs_groupe_etat -def test_abs_groupe_etat(): - r = requests.get( - SCODOC_URL - + "/ScoDoc/api/absences/abs_group_etat/?group_id=&date_debut=date_debut&date_fin=date_fin", - headers=HEADERS, - verify=CHECK_CERTIFICATE, - ) - assert r.status_code == 200 +# def test_abs_groupe_etat(): +# r = requests.get( +# SCODOC_URL +# + "/ScoDoc/api/absences/abs_group_etat/?group_id=&date_debut=date_debut&date_fin=date_fin", +# headers=HEADERS, +# verify=CHECK_CERTIFICATE, +# ) +# assert r.status_code == 200 diff --git a/tests/api/test_api_evaluations.py b/tests/api/test_api_evaluations.py index 1fb6ffbd..5fe3eb93 100644 --- a/tests/api/test_api_evaluations.py +++ b/tests/api/test_api_evaluations.py @@ -20,15 +20,45 @@ Utilisation : import requests from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS +from tests.api.tools_test_api import verify_fields + # evaluations def test_evaluations(): + fields = [ + "moduleimpl_id", + "jour", + "heure_debut", + "description", + "coefficient", + "publish_incomplete", + "numero", + "id", + "heure_fin", + "note_max", + "visibulletin", + "evaluation_type", + "evaluation_id", + "jouriso", + "duree", + "descrheure", + "matin", + "apresmidi", + ] + r = requests.get( SCODOC_URL + "/ScoDoc/api/evaluations/1", headers=HEADERS, verify=CHECK_CERTIFICATE, ) + + eval = r.json()[0] + + fields_OK = verify_fields(eval, fields) + assert r.status_code == 200 + # assert len(r.json()) == 1 + assert fields_OK is True # evaluation_notes