2022-03-09 16:52:07 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""Test Logos
|
|
|
|
|
|
|
|
Utilisation :
|
|
|
|
créer les variables d'environnement: (indiquer les valeurs
|
|
|
|
pour le serveur ScoDoc que vous voulez interroger)
|
|
|
|
|
|
|
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
|
|
|
export SCODOC_USER="xxx"
|
|
|
|
export SCODOC_PASSWD="xxx"
|
|
|
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
|
|
|
|
|
|
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
|
|
|
|
|
|
|
Lancer :
|
|
|
|
pytest tests/api/test_api_evaluations.py
|
|
|
|
"""
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
import requests
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
|
2022-06-23 16:20:19 +02:00
|
|
|
from tests.api.tools_test_api import (
|
|
|
|
verify_fields,
|
|
|
|
EVALUATIONS_FIELDS,
|
|
|
|
EVALUATION_FIELDS,
|
|
|
|
)
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_evaluations(api_headers):
|
|
|
|
"""
|
2022-05-06 16:05:34 +02:00
|
|
|
Test 'evaluations'
|
|
|
|
|
|
|
|
Route :
|
2022-07-30 08:23:22 +02:00
|
|
|
- /moduleimpl/<int:moduleimpl_id>/evaluations
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-06-23 16:20:19 +02:00
|
|
|
moduleimpl_id = 1
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-07-30 08:23:22 +02:00
|
|
|
f"{API_URL}/moduleimpl/{moduleimpl_id}/evaluations",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-06-23 16:20:19 +02:00
|
|
|
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["note_max"], float)
|
2022-11-01 11:19:28 +01:00
|
|
|
assert isinstance(eval["visi_bulletin"], bool)
|
2022-06-23 16:20:19 +02:00
|
|
|
assert isinstance(eval["evaluation_type"], int)
|
|
|
|
assert isinstance(eval["moduleimpl_id"], int)
|
|
|
|
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 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["moduleimpl_id"] == moduleimpl_id
|
|
|
|
|
|
|
|
|
2022-07-29 16:19:40 +02:00
|
|
|
def test_evaluation_notes(
|
|
|
|
api_headers,
|
|
|
|
): # XXX TODO changer la boucle pour parcourir le dict sans les indices
|
2022-06-23 16:20:19 +02:00
|
|
|
"""
|
|
|
|
Test 'evaluation_notes'
|
|
|
|
|
|
|
|
Route :
|
2022-07-29 16:19:40 +02:00
|
|
|
- /evaluation/<int:evaluation_id>/notes
|
2022-06-23 16:20:19 +02:00
|
|
|
"""
|
|
|
|
eval_id = 1
|
|
|
|
r = requests.get(
|
2022-07-29 16:19:40 +02:00
|
|
|
f"{API_URL}/evaluation/{eval_id}/notes",
|
2022-06-23 16:20:19 +02:00
|
|
|
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"]
|