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-05 20:06:49 +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-05 20:06:49 +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-11 00:59:51 +02:00
|
|
|
# Etudiant pour les tests
|
|
|
|
ETUDID = 1
|
|
|
|
NIP = "1"
|
|
|
|
INE = "INE1"
|
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
|
|
|
|
def test_formsemestre(api_headers):
|
|
|
|
"""
|
2022-05-05 19:50:09 +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-05 19:50:09 +02:00
|
|
|
assert verify_fields(formsemestre, FSEM_FIELDS)
|
2022-04-20 15:50:02 +02:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_etudiant_bulletin(api_headers):
|
|
|
|
"""
|
|
|
|
Route:
|
|
|
|
"""
|
2022-05-05 20:06:49 +02:00
|
|
|
formsemestre_id = 1
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-05-05 20:06:49 +02:00
|
|
|
f"{API_URL}/etudiant/etudid/1/formsemestre/{formsemestre_id}/bulletin",
|
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-05-05 20:06:49 +02:00
|
|
|
bull_a = r.json()
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-05-11 00:59:51 +02:00
|
|
|
f"{API_URL}/etudiant/nip/{NIP}/formsemestre/{formsemestre_id}/bulletin",
|
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-05-05 20:06:49 +02:00
|
|
|
bull_b = r.json()
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-05-11 00:59:51 +02:00
|
|
|
f"{API_URL}/etudiant/ine/{INE}/formsemestre/{formsemestre_id}/bulletin",
|
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-05-05 20:06:49 +02:00
|
|
|
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):
|
|
|
|
"""
|
|
|
|
Route:
|
|
|
|
"""
|
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-05 20:06:49 +02:00
|
|
|
|
|
|
|
def test_formsemestre_programme(api_headers):
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-05-05 20:06:49 +02:00
|
|
|
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-05 20:06:49 +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)
|
2022-06-02 16:18:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
# def test_formsemestre_etudiants(api_headers):
|
|
|
|
# """
|
|
|
|
# Route: /formsemestre/<int:formsemestre_id>/etudiants, /formsemestre/<int:formsemestre_id>/etudiants/demissionnaires, /formsemestre/<int:formsemestre_id>/etudiants/defaillants
|
|
|
|
# """
|
|
|
|
# r = requests.get(
|
|
|
|
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants",
|
|
|
|
# headers=api_headers,
|
|
|
|
# verify=CHECK_CERTIFICATE,
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
#
|
|
|
|
# r = requests.get(
|
|
|
|
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires",
|
|
|
|
# headers=api_headers,
|
|
|
|
# verify=CHECK_CERTIFICATE,
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
#
|
|
|
|
# r = requests.get(
|
|
|
|
# API_URL + "/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
|
|
|
|
# headers=api_headers,
|
|
|
|
# verify=CHECK_CERTIFICATE,
|
|
|
|
# )
|
|
|
|
# assert r.status_code == 200
|
|
|
|
|
|
|
|
|
|
|
|
def test_etat_evals(api_headers):
|
|
|
|
"""
|
|
|
|
Route : /formsemestre/<int:formsemestre_id>/etat_evals
|
|
|
|
"""
|
|
|
|
r = requests.get(
|
|
|
|
API_URL + "/formsemestre/1/etat_evals",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
|
|
|
)
|
|
|
|
assert r.status_code == 200
|