From 57414efec476052b5cc573617c0f2b7d59dc0123 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Thu, 23 Jun 2022 16:20:19 +0200 Subject: [PATCH] ajout des tests de evaluations --- tests/api/test_api_evaluations.py | 77 +++++++++++++++++++++------- tests/api/tools_test_api.py | 83 +++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 17 deletions(-) diff --git a/tests/api/test_api_evaluations.py b/tests/api/test_api_evaluations.py index 1453f3a12..57bb2b5cf 100644 --- a/tests/api/test_api_evaluations.py +++ b/tests/api/test_api_evaluations.py @@ -20,6 +20,11 @@ Utilisation : import requests from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers +from tests.api.tools_test_api import ( + verify_fields, + EVALUATIONS_FIELDS, + EVALUATION_FIELDS, +) def test_evaluations(api_headers): @@ -29,27 +34,65 @@ def test_evaluations(api_headers): Route : - /evaluations/ """ + moduleimpl_id = 1 r = requests.get( - API_URL + "/evaluations/1", + f"{API_URL}/evaluations/{moduleimpl_id}", headers=api_headers, verify=CHECK_CERTIFICATE, ) assert r.status_code == 200 - # TODO + list_eval = r.json() + assert isinstance(list_eval, list) + for eval in list_eval: + assert verify_fields(eval, EVALUATIONS_FIELDS) is True + assert isinstance(eval["id"], int) + assert isinstance(eval["jour"], str) + assert isinstance(eval["heure_fin"], str) + assert isinstance(eval["note_max"], float) + assert isinstance(eval["visibulletin"], bool) + assert isinstance(eval["evaluation_type"], int) + assert isinstance(eval["moduleimpl_id"], int) + assert isinstance(eval["heure_debut"], str) + assert eval["description"] is None or isinstance(eval["description"], str) + assert isinstance(eval["coefficient"], float) + assert isinstance(eval["publish_incomplete"], bool) + assert isinstance(eval["numero"], int) + assert isinstance(eval["evaluation_id"], int) + assert eval["date_debut"] is None or isinstance(eval["date_debut"], str) + assert eval["date_fin"] is None or isinstance(eval["date_fin"], str) + assert isinstance(eval["poids"], dict) + assert eval["jouriso"] is None or isinstance(eval["jouriso"], str) + assert isinstance(eval["duree"], str) + assert isinstance(eval["descrheure"], str) + assert isinstance(eval["matin"], int) + assert isinstance(eval["apresmidi"], int) + + assert eval["moduleimpl_id"] == moduleimpl_id -# TODO car pas d'évaluations créées à ce stade -# def test_evaluation_notes(api_headers): -# """ -# Test 'evaluation_notes' -# -# Route : -# - /evaluation/eval_notes/ -# """ -# r = requests.get( -# API_URL + "/evaluation/eval_notes/1", -# headers=api_headers, -# verify=CHECK_CERTIFICATE, -# ) -# assert r.status_code == 200 -# # TODO +def test_evaluation_notes(api_headers): + """ + Test 'evaluation_notes' + + Route : + - /evaluation/eval_notes/ + """ + eval_id = 1 + r = requests.get( + f"{API_URL}/evaluation/eval_notes/{eval_id}", + headers=api_headers, + verify=CHECK_CERTIFICATE, + ) + assert r.status_code == 200 + eval_notes = r.json() + for i in range(1, len(eval_notes)): + assert verify_fields(eval_notes[f"{i}"], EVALUATION_FIELDS) + assert isinstance(eval_notes[f"{i}"]["id"], int) + assert isinstance(eval_notes[f"{i}"]["etudid"], int) + assert isinstance(eval_notes[f"{i}"]["evaluation_id"], int) + assert isinstance(eval_notes[f"{i}"]["value"], float) + assert isinstance(eval_notes[f"{i}"]["comment"], str) + assert isinstance(eval_notes[f"{i}"]["date"], str) + assert isinstance(eval_notes[f"{i}"]["uid"], int) + + assert eval_id == eval_notes[f"{i}"]["evaluation_id"] diff --git a/tests/api/tools_test_api.py b/tests/api/tools_test_api.py index 41147cf52..f6d9c4538 100644 --- a/tests/api/tools_test_api.py +++ b/tests/api/tools_test_api.py @@ -558,3 +558,86 @@ FORMSEMESTRE_ETUS_GROUPS_FIELDS = { "group_id", "group_name", } + +EVALUATIONS_FIELDS = { + "id", + "jour", + "heure_fin", + "note_max", + "visibulletin", + "evaluation_type", + "moduleimpl_id", + "heure_debut", + "description", + "coefficient", + "publish_incomplete", + "numero", + "evaluation_id", + "date_debut", + "date_fin", + "poids", + "jouriso", + "duree", + "descrheure", + "matin", + "apresmidi", +} + +EVALUATION_FIELDS = { + "id", + "etudid", + "evaluation_id", + "value", + "comment", + "date", + "uid", +} + + +PARTITIONS_FIELDS = { + "partition_id", + "id", + "formsemestre_id", + "partition_name", + "numero", + "bul_show_rank", + "show_in_lists", +} + +PARTITIONS_GROUPS_ETU_FIELDS = { + "etudid", + "id", + "dept_id", + "nom", + "prenom", + "nom_usuel", + "civilite", + "date_naissance", + "lieu_naissance", + "dept_naissance", + "nationalite", + "statut", + "boursier", + "photo_filename", + "code_nip", + "code_ine", + "scodoc7_id", + "email", + "emailperso", + "domicile", + "codepostaldomicile", + "villedomicile", + "paysdomicile", + "telephone", + "telephonemobile", + "fax", + "typeadresse", + "description", + "group_id", + "etat", + "civilite_str", + "nom_disp", + "nomprenom", + "ne", + "email_default", +}