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
|
|
|
|
2023-04-06 10:38:31 +02:00
|
|
|
from app.scodoc import sco_utils as scu
|
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,
|
2023-06-03 22:43:04 +02:00
|
|
|
NOTES_FIELDS,
|
2022-06-23 16:20:19 +02:00
|
|
|
)
|
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
|
|
|
"""
|
2023-06-03 22:43:04 +02:00
|
|
|
moduleimpl_id = 20
|
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,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-04-13 12:39:10 +02:00
|
|
|
)
|
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()
|
2023-06-03 22:43:04 +02:00
|
|
|
assert list_eval
|
2022-06-23 16:20:19 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2023-06-03 22:43:04 +02:00
|
|
|
def test_evaluation_notes(api_headers):
|
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
|
|
|
"""
|
2023-06-03 22:43:04 +02:00
|
|
|
eval_id = 20
|
2022-06-23 16:20:19 +02:00
|
|
|
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,
|
2023-04-06 11:48:36 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-23 16:20:19 +02:00
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
|
|
|
eval_notes = r.json()
|
2023-06-03 22:43:04 +02:00
|
|
|
assert eval_notes
|
|
|
|
for etudid, note in eval_notes.items():
|
|
|
|
assert int(etudid) == note["etudid"]
|
|
|
|
assert verify_fields(note, NOTES_FIELDS)
|
|
|
|
assert isinstance(note["etudid"], int)
|
|
|
|
assert isinstance(note["evaluation_id"], int)
|
|
|
|
assert isinstance(note["value"], float)
|
|
|
|
assert isinstance(note["comment"], str)
|
|
|
|
assert isinstance(note["date"], str)
|
|
|
|
assert isinstance(note["uid"], int)
|
2022-06-23 16:20:19 +02:00
|
|
|
|
2023-06-03 22:43:04 +02:00
|
|
|
assert eval_id == note["evaluation_id"]
|