forked from ScoDoc/DocScoDoc
amélioration des asserts de departement et etudiant
This commit is contained in:
parent
8e36201482
commit
a43f1e0e22
@ -16,8 +16,8 @@ from app.scodoc.sco_saisie_notes import notes_add
|
||||
|
||||
|
||||
@bp.route("/departements", methods=["GET"])
|
||||
# @token_auth.login_required # Commenté le temps des tests
|
||||
# @permission_required(Permission.APIView)
|
||||
@token_auth.login_required # Commenté le temps des tests
|
||||
# @permission_required(Permission.ScoView)
|
||||
def departements():
|
||||
"""
|
||||
Retourne la liste des ids de départements visibles
|
||||
@ -35,7 +35,7 @@ def departements():
|
||||
|
||||
@bp.route("/departements/<string:dept>/etudiants/liste", methods=["GET"])
|
||||
@bp.route("/departements/<string:dept>/etudiants/liste/<int:formsemestre_id>", methods=["GET"])
|
||||
# @token_auth.login_required
|
||||
@token_auth.login_required
|
||||
# @permission_required(Permission.APIView)
|
||||
def liste_etudiants(dept: str, formsemestre_id=None):
|
||||
"""
|
||||
@ -94,51 +94,6 @@ def liste_etudiants(dept: str, formsemestre_id=None):
|
||||
return jsonify(list_etu)
|
||||
|
||||
|
||||
# Si le formsemestre_id a été renseigné
|
||||
# if formsemestre_id is not None:
|
||||
# a = 0
|
||||
# Récupération du/des depts
|
||||
# list_depts = models.Departement.query.filter(
|
||||
# models.Departement.acronym == dept,
|
||||
# models.FormSemestre.id == formsemestre_id,
|
||||
# )
|
||||
#
|
||||
# formsemestre = models.FormSemestre.query.get_or_404(formsemestre_id)
|
||||
# list_depts = formsemestre.departement
|
||||
# print(formsemestre)
|
||||
#
|
||||
# dept_id = list_depts
|
||||
|
||||
|
||||
# list_etuds = []
|
||||
# for dept in list_depts:
|
||||
# # Récupération des étudiants d'un département
|
||||
# etudiants = models.Identite.query.filter_by(dept_id=dept.id).all()
|
||||
# print(etudiants)
|
||||
# for etu in etudiants:
|
||||
# # Ajout des étudiants dans la liste global
|
||||
# list_etuds.append(etu)
|
||||
|
||||
# Si le formsemestre_id n'a pas été renseigné
|
||||
# else:
|
||||
|
||||
# # list_depts = models.Departement.query.filter(
|
||||
# # models.Departement.acronym == dept,
|
||||
# # models.FormSemestre.id == formsemestre_id,
|
||||
# # )
|
||||
#
|
||||
# list_etuds = []
|
||||
# for dept in list_depts:
|
||||
# etudiants = models.Identite.query.filter_by(dept_id=dept.id).all()
|
||||
# for etu in etudiants:
|
||||
# list_etuds.append(etu)
|
||||
#
|
||||
# # Mise en forme des données
|
||||
# data = [d.to_dict_bul() for d in list_etuds]
|
||||
# return jsonify(data)
|
||||
# return error_response(501, message="Not implemented")
|
||||
|
||||
|
||||
@bp.route("/departements/<string:dept>/semestres_courants", methods=["GET"])
|
||||
# @token_auth.login_required # Commenté le temps des tests
|
||||
# @permission_required(Permission.APIView)
|
||||
|
@ -43,8 +43,6 @@ def get_departement():
|
||||
|
||||
get_token()
|
||||
|
||||
print("ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé")
|
||||
|
||||
global HEADERS
|
||||
global CHECK_CERTIFICATE
|
||||
global SCODOC_USER
|
||||
@ -57,8 +55,6 @@ def get_departement():
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
|
||||
print("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii")
|
||||
|
||||
if r.status_code == 200:
|
||||
dept_id = r.json()[0]
|
||||
# print(dept_id)
|
||||
|
@ -28,30 +28,34 @@ def test_departements():
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
|
||||
|
||||
# liste_etudiants
|
||||
def test_etudiants():
|
||||
def test_liste_etudiants():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 16
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 16
|
||||
|
||||
|
||||
# liste_semestres_courant
|
||||
def test_semestres_courant():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1",
|
||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
|
||||
|
||||
# referenciel_competences
|
||||
|
@ -16,6 +16,7 @@ Utilisation :
|
||||
Lancer :
|
||||
pytest tests/api/test_api_etudiants.py
|
||||
"""
|
||||
from random import randint
|
||||
|
||||
import requests
|
||||
from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||
@ -24,26 +25,46 @@ from tests.api.setup_test_api import SCODOC_URL, HEADERS, CHECK_CERTIFICATE
|
||||
# etudiants
|
||||
def test_etudiants():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiants",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
SCODOC_URL + "/ScoDoc/api/etudiants",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 16
|
||||
|
||||
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
||||
etu = r.json()[randint(0, len(r.json()))-1]
|
||||
|
||||
fields = ["civilite", "code_ine", "code_nip", "date_naissance", "email", "emailperso", "etudid", "nom",
|
||||
"prenom", "nomprenom"]
|
||||
|
||||
fields_OK = True
|
||||
|
||||
# Vérifie si tous les champs sont bien présents
|
||||
for field in etu:
|
||||
if field not in fields:
|
||||
fields_OK = False
|
||||
|
||||
assert fields_OK is True
|
||||
|
||||
|
||||
# etudiants_courant
|
||||
def test_etudiants_courant():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 0
|
||||
|
||||
|
||||
# etudiant
|
||||
def test_etudiant():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 10
|
||||
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>",
|
||||
@ -60,10 +81,11 @@ def test_etudiant():
|
||||
# etudiant_formsemestres
|
||||
def test_etudiant_formsemestres():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestres",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestres",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/formsemestres",
|
||||
@ -79,12 +101,14 @@ def test_etudiant_formsemestres():
|
||||
|
||||
|
||||
# etudiant_bulletin_semestre
|
||||
def test_etudiant_bulletin_semestre():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
# def test_etudiant_bulletin_semestre():
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
||||
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
# assert len(r.json()) == 1
|
||||
|
||||
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/formsemestre/<int:formsemestre_id>/bulletin",
|
||||
@ -102,10 +126,12 @@ def test_etudiant_bulletin_semestre():
|
||||
# etudiant_groups
|
||||
def test_etudiant_groups():
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/semestre/1/groups",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/semestre/1/groups",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
|
||||
|
||||
# r = requests.get(
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/nip/<int:nip>/semestre/<int:formsemestre_id>/groups",
|
||||
@ -117,4 +143,4 @@ def test_etudiant_groups():
|
||||
# SCODOC_URL + "/ScoDoc/api/etudiant/ine/<int:ine>/semestre/<int:formsemestre_id>/groups",
|
||||
# headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
# )
|
||||
# assert r.status_code == 200
|
||||
# assert r.status_code == 200
|
||||
|
Loading…
Reference in New Issue
Block a user