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_formsemestre.py
|
|
|
|
"""
|
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
import requests
|
2022-05-09 16:26:23 +02:00
|
|
|
from app.api.formsemestres import formsemestre
|
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-05-09 16:26:23 +02:00
|
|
|
from tests.api.tools_test_api import MODIMPL_FIELDS, verify_fields
|
|
|
|
from tests.api.tools_test_api import FSEM_FIELDS, UE_FIELDS, MODULE_FIELDS
|
2022-05-02 16:29:26 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
|
|
|
|
def test_formsemestre(api_headers):
|
|
|
|
"""
|
2022-05-09 16:26:23 +02:00
|
|
|
Route: /formsemestre/<id>
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-05-04 23:11:20 +02:00
|
|
|
API_URL + "/formsemestre/1",
|
|
|
|
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-04-20 15:50:02 +02:00
|
|
|
formsemestre = r.json()
|
2022-05-09 16:26:23 +02:00
|
|
|
assert verify_fields(formsemestre, FSEM_FIELDS)
|
2022-04-20 15:50:02 +02:00
|
|
|
|
2022-05-09 16:26:23 +02:00
|
|
|
|
|
|
|
def test_etudiant_bulletin(api_headers):
|
|
|
|
"""
|
|
|
|
Route:
|
|
|
|
"""
|
|
|
|
formsemestre_id = 1
|
|
|
|
r = requests.get(
|
|
|
|
f"{API_URL}/etudiant/etudid/1/formsemestre/{formsemestre_id}/bulletin",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
|
|
|
bull_a = r.json()
|
|
|
|
|
|
|
|
r = requests.get(
|
|
|
|
f"{API_URL}/etudiant/nip/1/formsemestre/{formsemestre_id}/bulletin",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
|
|
|
bull_b = r.json()
|
|
|
|
|
|
|
|
r = requests.get(
|
|
|
|
f"{API_URL}/etudiant/ine/1/formsemestre/{formsemestre_id}/bulletin",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
|
|
|
bull_c = r.json()
|
|
|
|
# elimine les dates de publication pour comparer les autres champs
|
|
|
|
del bull_a["date"]
|
|
|
|
del bull_b["date"]
|
|
|
|
del bull_c["date"]
|
|
|
|
assert bull_a == bull_b == bull_c
|
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_bulletins(api_headers):
|
|
|
|
"""
|
2022-05-09 16:26:23 +02:00
|
|
|
Route:
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-04-27 14:11:06 +02:00
|
|
|
r = requests.get(
|
2022-05-04 23:11:20 +02:00
|
|
|
API_URL + "/formsemestre/1/bulletins",
|
|
|
|
headers=api_headers,
|
2022-04-27 14:11:06 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
|
|
|
|
|
|
|
|
2022-04-20 15:50:02 +02:00
|
|
|
# # jury
|
|
|
|
# def test_jury():
|
|
|
|
# r = requests.get(
|
2022-05-04 23:11:20 +02:00
|
|
|
# API_URL + "/formsemestre/1/jury",
|
|
|
|
# headers=api_headers,
|
2022-04-20 15:50:02 +02:00
|
|
|
# verify=CHECK_CERTIFICATE,
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
2022-05-02 16:29:26 +02:00
|
|
|
|
2022-05-06 16:05:34 +02:00
|
|
|
|
2022-05-09 16:26:23 +02:00
|
|
|
def test_formsemestre_programme(api_headers):
|
|
|
|
"""
|
|
|
|
Route: /formsemestre/1/programme
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-05-02 16:29:26 +02:00
|
|
|
|
|
|
|
r = requests.get(
|
2022-05-04 23:11:20 +02:00
|
|
|
API_URL + "/formsemestre/1/programme",
|
|
|
|
headers=api_headers,
|
2022-05-02 16:29:26 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|
2022-05-09 16:26:23 +02:00
|
|
|
prog = r.json()
|
|
|
|
assert isinstance(prog, dict)
|
|
|
|
assert "ues" in prog
|
|
|
|
assert "modules" in prog
|
|
|
|
assert "ressources" in prog
|
|
|
|
assert "saes" in prog
|
|
|
|
assert isinstance(prog["ues"], list)
|
|
|
|
assert isinstance(prog["modules"], list)
|
|
|
|
ue = prog["ues"][0]
|
|
|
|
modules = prog["modules"]
|
|
|
|
# Il y a toujours au moins une SAE et une ressources dans notre base de test
|
|
|
|
ressource = prog["ressources"][0]
|
|
|
|
sae = prog["saes"][0]
|
|
|
|
|
|
|
|
assert verify_fields(ue, UE_FIELDS)
|
|
|
|
if len(modules) > 1:
|
|
|
|
assert verify_fields(modules[0], MODIMPL_FIELDS)
|
|
|
|
assert verify_fields(ressource, MODIMPL_FIELDS)
|
|
|
|
assert verify_fields(sae, MODIMPL_FIELDS)
|