forked from ScoDoc/ScoDoc
Prise en compte des remarques du 26/04/2022 sur différents fichiers de /api
This commit is contained in:
parent
ce2b7334c6
commit
46d99a5735
@ -33,4 +33,3 @@ from app.api import evaluations
|
||||
from app.api import jury
|
||||
from app.api import absences
|
||||
from app.api import logos
|
||||
|
||||
|
@ -7,7 +7,7 @@ from app import models
|
||||
from app.api import bp
|
||||
from app.api.errors import error_response
|
||||
from app.api.auth import token_permission_required
|
||||
from app.api.tools import get_etu_from_request
|
||||
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||
from app.scodoc.sco_abs import (
|
||||
add_absence,
|
||||
add_justif,
|
||||
@ -34,7 +34,7 @@ def absences(etudid: int = None, nip: int = None, ine: int = None):
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
@ -44,7 +44,7 @@ def absences(etudid: int = None, nip: int = None, ine: int = None):
|
||||
)
|
||||
|
||||
# Récupération des absences de l'étudiant
|
||||
abs = models.Absence.query.filter_by(etudid=etudid).all()
|
||||
abs = models.Absence.query.filter_by(etudid=etudid)
|
||||
|
||||
# Si l'étudiant a au minimum une absence
|
||||
if len(abs) > 0:
|
||||
@ -71,7 +71,7 @@ def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
@ -81,7 +81,7 @@ def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
||||
)
|
||||
|
||||
# Récupération des absences justifiées de l'étudiant
|
||||
abs = models.Absence.query.filter_by(etudid=etudid, estjust=True).all()
|
||||
abs = models.Absence.query.filter_by(etudid=etudid, estjust=True)
|
||||
|
||||
# Si l'étudiant a au minimum une absence justifiées
|
||||
if len(abs) > 0:
|
||||
@ -95,75 +95,6 @@ def absences_justify(etudid: int = None, nip: int = None, ine: int = None):
|
||||
)
|
||||
|
||||
|
||||
### Inutil en définitif ###
|
||||
@bp.route(
|
||||
"/absences/abs_signale?etudid=<int:etudid>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
"&description=<string:description>",
|
||||
methods=["POST"],
|
||||
)
|
||||
@bp.route(
|
||||
"/absences/abs_signale?nip=<int:nip>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
"&description=<string:description>",
|
||||
methods=["POST"],
|
||||
)
|
||||
@bp.route(
|
||||
"/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
"&description=<string:description>",
|
||||
methods=["POST"],
|
||||
)
|
||||
@bp.route(
|
||||
"/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
"&description=<string:description>&moduleimpl_id=<int:moduleimpl_id>",
|
||||
methods=["POST"],
|
||||
)
|
||||
@token_permission_required(Permission.APIAbsChange)
|
||||
def abs_signale(
|
||||
date: datetime,
|
||||
matin: bool,
|
||||
justif: bool,
|
||||
etudid: int = None,
|
||||
nip: int = None,
|
||||
ine: int = None, ### Inutil en définitif
|
||||
description: str = None,
|
||||
moduleimpl_id: int = None,
|
||||
):
|
||||
"""
|
||||
Permet d'ajouter une absence en base
|
||||
|
||||
date : la date de l'absence
|
||||
matin : True ou False
|
||||
justif : True ou False
|
||||
etudid : l'etudid d'un étudiant
|
||||
nip: le code nip d'un étudiant
|
||||
ine : le code ine d'un étudiant
|
||||
description : description possible à ajouter sur l'absence
|
||||
moduleimpl_id : l'id d'un moduleimpl
|
||||
"""
|
||||
# Fonctions utilisées : app.scodoc.sco_abs.add_absence() et app.scodoc.sco_abs.add_justif()
|
||||
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
409,
|
||||
message="La requête ne peut être traitée en l’état actuel.\n "
|
||||
"Veilliez vérifier que l'id de l'étudiant (etudid, nip, ine) est valide",
|
||||
)
|
||||
try:
|
||||
# Utilisation de la fonction add_absence
|
||||
add_absence(etudid, date, matin, justif, description, moduleimpl_id)
|
||||
if justif == True:
|
||||
# Utilisation de la fonction add_justif
|
||||
add_justif(etudid, date, matin, description)
|
||||
except ValueError:
|
||||
return error_response(
|
||||
409, message="La requête ne peut être traitée en l’état actuel"
|
||||
)
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/absences/abs_annule?etudid=<int:etudid>&jour=<string:jour>&matin=<string:matin>",
|
||||
methods=["POST"],
|
||||
@ -194,7 +125,7 @@ def abs_annule(
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
@ -246,7 +177,7 @@ def abs_annule_justif(
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
|
@ -67,7 +67,9 @@ def liste_etudiants(dept: str, formsemestre_id=None):
|
||||
# Si le formsemestre_id a été renseigné
|
||||
if formsemestre_id is not None:
|
||||
# Récupération du formsemestre
|
||||
formsemestre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
||||
formsemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
# Récupération du département
|
||||
departement = formsemestre.departement
|
||||
|
||||
@ -180,7 +182,9 @@ def semestre_index(dept: str, formsemestre_id: int):
|
||||
|
||||
app.set_sco_dept(dept)
|
||||
|
||||
formsemestre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
||||
formsemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
|
||||
ues = formsemestre.query_ues()
|
||||
|
||||
|
@ -7,7 +7,7 @@ from app import models
|
||||
from app.api import bp
|
||||
from app.api.errors import error_response
|
||||
from app.api.auth import token_permission_required
|
||||
from app.api.tools import get_etu_from_request
|
||||
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||
from app.models import FormSemestreInscription, FormSemestre, Identite
|
||||
from app.scodoc import sco_bulletins
|
||||
from app.scodoc import sco_groups
|
||||
@ -21,6 +21,7 @@ def etudiants_courant():
|
||||
Retourne la liste des étudiants courant
|
||||
|
||||
Exemple de résultat :
|
||||
{
|
||||
{
|
||||
"civilite": "X",
|
||||
"code_ine": null,
|
||||
@ -44,6 +45,7 @@ def etudiants_courant():
|
||||
"prenom": "ANNE"
|
||||
},
|
||||
...
|
||||
}
|
||||
"""
|
||||
# Récupération de tous les étudiants
|
||||
etuds = Identite.query.filter(
|
||||
@ -84,7 +86,7 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
||||
}
|
||||
"""
|
||||
# Récupération de l'étudiant
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
|
||||
# Mise en forme des données
|
||||
data = etu.to_dict_bul(include_urls=False)
|
||||
@ -98,7 +100,7 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
|
||||
@token_permission_required(Permission.APIView)
|
||||
def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None):
|
||||
"""
|
||||
Retourne la liste des semestres qu'un étudiant a suivi, triés par ordre chronologique.
|
||||
Retourne la liste des semestres qu'un étudiant a suivis, triés par ordre chronologique.
|
||||
|
||||
etudid : l'etudid d'un étudiant
|
||||
nip : le code nip d'un étudiant
|
||||
@ -139,7 +141,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
||||
]
|
||||
"""
|
||||
# Récupération de l'étudiant
|
||||
etud = get_etu_from_request(etudid, nip, ine)
|
||||
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
|
||||
formsemestres = models.FormSemestre.query.filter(
|
||||
models.FormSemestreInscription.etudid == etud.id,
|
||||
@ -185,7 +187,7 @@ def etudiant_bulletin_semestre(
|
||||
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
409,
|
||||
@ -247,7 +249,7 @@ def etudiant_groups(
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
|
@ -5,15 +5,12 @@ import app
|
||||
from app import models
|
||||
from app.api import bp
|
||||
from app.api.errors import error_response
|
||||
from app.api.auth import token_auth, token_permission_required
|
||||
from app.api.tools import get_etu_from_request
|
||||
from app.api.auth import token_permission_required
|
||||
from app.api.tools import get_etu_from_etudid_or_nip_or_ine
|
||||
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
|
||||
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
from app.scodoc.sco_pvjury import formsemestre_pvjury
|
||||
from app.scodoc.sco_recapcomplet import (
|
||||
formsemestre_recapcomplet,
|
||||
gen_formsemestre_recapcomplet_json,
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/formations/formsemestre/<int:formsemestre_id>", methods=["GET"])
|
||||
@ -26,7 +23,7 @@ def formsemestre(formsemestre_id: int):
|
||||
|
||||
"""
|
||||
# Récupération de tous les formsemestres
|
||||
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
|
||||
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
|
||||
|
||||
# Mise en forme des données
|
||||
data = formsemetre.to_dict()
|
||||
@ -78,7 +75,7 @@ def etudiant_bulletin(
|
||||
if etudid is None:
|
||||
# Récupération de l'étudiant
|
||||
try:
|
||||
etu = get_etu_from_request(etudid, nip, ine)
|
||||
etu = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
|
||||
etudid = etu.etudid
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
@ -103,9 +100,7 @@ def etudiant_bulletin(
|
||||
# return jsonify(data)
|
||||
|
||||
|
||||
@bp.route(
|
||||
"/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"]
|
||||
) # XXX TODO à revoir
|
||||
@bp.route("/formsemestre/<int:formsemestre_id>/bulletins", methods=["GET"])
|
||||
@token_permission_required(Permission.APIView)
|
||||
def bulletins(formsemestre_id: int):
|
||||
"""
|
||||
@ -113,19 +108,22 @@ def bulletins(formsemestre_id: int):
|
||||
|
||||
formsemestre_id : l'id d'un formesemestre
|
||||
"""
|
||||
# Fonction utilisée : app.scodoc.sco_recapcomplet.formsemestre_recapcomplet()
|
||||
# gen_formsemestre_recapcomplet_json ??
|
||||
# Fonction utilisée : app.scodoc.sco_bulletins.get_formsemestre_bulletin_etud_json()
|
||||
|
||||
try:
|
||||
# Utilisation de la fonction formsemestre_recapcomplet
|
||||
# data = formsemestre_recapcomplet(formsemestre_id)
|
||||
data = gen_formsemestre_recapcomplet_json(formsemestre_id)
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
409,
|
||||
message="La requête ne peut être traitée en l’état actuel. \n"
|
||||
"Veillez vérifier la conformité du 'formation_id'",
|
||||
)
|
||||
formsemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
|
||||
dept = models.Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
||||
|
||||
app.set_sco_dept(dept.acronym)
|
||||
|
||||
etuds = formsemestre.etuds
|
||||
|
||||
data = []
|
||||
for etu in etuds:
|
||||
bul_etu = get_formsemestre_bulletin_etud_json(formsemestre, etu)
|
||||
data.append(bul_etu.json)
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
@ -140,14 +138,24 @@ def jury(formsemestre_id: int):
|
||||
"""
|
||||
# Fonction utilisée : app.scodoc.sco_pvjury.formsemestre_pvjury()
|
||||
|
||||
try:
|
||||
# Utilisation de la fonction formsemestre_pvjury
|
||||
formsemestre = models.FormSemestre.query.filter_by(
|
||||
id=formsemestre_id
|
||||
).first_or_404()
|
||||
|
||||
dept = models.Departement.query.filter_by(id=formsemestre.dept_id).first_or_404()
|
||||
|
||||
app.set_sco_dept(dept.acronym)
|
||||
|
||||
data = formsemestre_pvjury(formsemestre_id)
|
||||
except AttributeError:
|
||||
return error_response(
|
||||
409,
|
||||
message="La requête ne peut être traitée en l’état actuel. \n"
|
||||
"Veillez vérifier la conformité du 'formation_id'",
|
||||
)
|
||||
|
||||
# try:
|
||||
# # Utilisation de la fonction formsemestre_pvjury
|
||||
# data = formsemestre_pvjury(formsemestre_id)
|
||||
# except AttributeError:
|
||||
# return error_response(
|
||||
# 409,
|
||||
# message="La requête ne peut être traitée en l’état actuel. \n"
|
||||
# "Veillez vérifier la conformité du 'formation_id'",
|
||||
# )
|
||||
|
||||
return jsonify(data)
|
||||
|
@ -19,7 +19,7 @@ def partition(formsemestre_id: int):
|
||||
formsemestre_id : l'id d'un formsemestre
|
||||
"""
|
||||
# Récupération de toutes les partitions
|
||||
partitions = models.Partition.query.filter_by(id=formsemestre_id).all()
|
||||
partitions = models.Partition.query.filter_by(id=formsemestre_id)
|
||||
|
||||
# Mise en forme des données
|
||||
data = [d.to_dict() for d in partitions]
|
||||
|
@ -38,8 +38,6 @@
|
||||
# return jsonify(data)
|
||||
|
||||
|
||||
|
||||
|
||||
# @bp.route(
|
||||
# "/evaluations/eval_set_notes?eval_id=<int:eval_id>&etudid=<int:etudid>¬e=<float:note>",
|
||||
# methods=["POST"],
|
||||
@ -70,3 +68,72 @@
|
||||
# # Qu'est ce qu'un user ???
|
||||
# # notes_add()
|
||||
# return error_response(501, message="Not implemented")
|
||||
|
||||
|
||||
# ### Inutil en définitif ###
|
||||
# @bp.route(
|
||||
# "/absences/abs_signale?etudid=<int:etudid>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
# "&description=<string:description>",
|
||||
# methods=["POST"],
|
||||
# )
|
||||
# @bp.route(
|
||||
# "/absences/abs_signale?nip=<int:nip>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
# "&description=<string:description>",
|
||||
# methods=["POST"],
|
||||
# )
|
||||
# @bp.route(
|
||||
# "/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
# "&description=<string:description>",
|
||||
# methods=["POST"],
|
||||
# )
|
||||
# @bp.route(
|
||||
# "/absences/abs_signale?ine=<int:ine>&date=<string:date>&matin=<string:matin>&justif=<string:justif>"
|
||||
# "&description=<string:description>&moduleimpl_id=<int:moduleimpl_id>",
|
||||
# methods=["POST"],
|
||||
# )
|
||||
# @token_permission_required(Permission.APIAbsChange)
|
||||
# def abs_signale(
|
||||
# date: datetime,
|
||||
# matin: bool,
|
||||
# justif: bool,
|
||||
# etudid: int = None,
|
||||
# nip: int = None,
|
||||
# ine: int = None, ### Inutil en définitif
|
||||
# description: str = None,
|
||||
# moduleimpl_id: int = None,
|
||||
# ):
|
||||
# """
|
||||
# Permet d'ajouter une absence en base
|
||||
#
|
||||
# date : la date de l'absence
|
||||
# matin : True ou False
|
||||
# justif : True ou False
|
||||
# etudid : l'etudid d'un étudiant
|
||||
# nip: le code nip d'un étudiant
|
||||
# ine : le code ine d'un étudiant
|
||||
# description : description possible à ajouter sur l'absence
|
||||
# moduleimpl_id : l'id d'un moduleimpl
|
||||
# """
|
||||
# # Fonctions utilisées : app.scodoc.sco_abs.add_absence() et app.scodoc.sco_abs.add_justif()
|
||||
#
|
||||
# if etudid is None:
|
||||
# # Récupération de l'étudiant
|
||||
# try:
|
||||
# etu = get_etu_from_request(etudid, nip, ine)
|
||||
# etudid = etu.etudid
|
||||
# except AttributeError:
|
||||
# return error_response(
|
||||
# 409,
|
||||
# message="La requête ne peut être traitée en l’état actuel.\n "
|
||||
# "Veilliez vérifier que l'id de l'étudiant (etudid, nip, ine) est valide",
|
||||
# )
|
||||
# try:
|
||||
# # Utilisation de la fonction add_absence
|
||||
# add_absence(etudid, date, matin, justif, description, moduleimpl_id)
|
||||
# if justif == True:
|
||||
# # Utilisation de la fonction add_justif
|
||||
# add_justif(etudid, date, matin, description)
|
||||
# except ValueError:
|
||||
# return error_response(
|
||||
# 409, message="La requête ne peut être traitée en l’état actuel"
|
||||
# )
|
||||
|
@ -50,19 +50,26 @@ from app.api.errors import error_response
|
||||
from app import models
|
||||
from app.models import FormSemestre, FormSemestreInscription, Identite
|
||||
from app.models import ApcReferentielCompetences
|
||||
from app.scodoc.sco_abs import annule_absence, annule_justif, add_absence, add_justif, list_abs_date
|
||||
from app.scodoc.sco_abs import (
|
||||
annule_absence,
|
||||
annule_justif,
|
||||
add_absence,
|
||||
add_justif,
|
||||
list_abs_date,
|
||||
)
|
||||
from app.scodoc.sco_bulletins import formsemestre_bulletinetud_dict
|
||||
from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud
|
||||
from app.scodoc.sco_evaluation_db import do_evaluation_get_all_notes
|
||||
from app.scodoc.sco_formations import formation_export
|
||||
from app.scodoc.sco_formsemestre_inscriptions import do_formsemestre_inscription_listinscrits
|
||||
from app.scodoc.sco_formsemestre_inscriptions import (
|
||||
do_formsemestre_inscription_listinscrits,
|
||||
)
|
||||
from app.scodoc.sco_groups import setGroups, get_etud_groups, get_group_members
|
||||
from app.scodoc.sco_logos import list_logos, find_logo, _list_dept_logos
|
||||
from app.scodoc.sco_moduleimpl import moduleimpl_list
|
||||
from app.scodoc.sco_permissions import Permission
|
||||
|
||||
|
||||
|
||||
# ###################################################### Logos ##########################################################
|
||||
#
|
||||
# # XXX TODO voir get_logo déjà existant dans app/views/scodoc.py
|
||||
@ -143,5 +150,3 @@ from app.scodoc.sco_permissions import Permission
|
||||
# # return error_response(200, message="Aucun logo trouvé correspondant aux informations renseignés")
|
||||
# #
|
||||
# # return res
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from app import models
|
||||
|
||||
|
||||
def get_etu_from_request(etudid, nip, ine):
|
||||
def get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine):
|
||||
"""
|
||||
Fonction qui retourne un etudiant en fonction de l'etudid, code nip et code ine rentré en paramètres
|
||||
|
||||
|
@ -23,55 +23,55 @@ import requests
|
||||
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
||||
|
||||
|
||||
# etudiants
|
||||
def test_etudiants():
|
||||
|
||||
fields = [
|
||||
"civilite",
|
||||
"code_ine",
|
||||
"code_nip",
|
||||
"date_naissance",
|
||||
"email",
|
||||
"emailperso",
|
||||
"etudid",
|
||||
"nom",
|
||||
"prenom",
|
||||
"nomprenom",
|
||||
"lieu_naissance",
|
||||
"dept_naissance",
|
||||
"nationalite",
|
||||
"boursier",
|
||||
"id",
|
||||
"domicile",
|
||||
"villedomicile",
|
||||
"telephone",
|
||||
"fax",
|
||||
"description",
|
||||
"codepostaldomicile",
|
||||
"paysdomicile",
|
||||
"telephonemobile",
|
||||
"typeadresse",
|
||||
]
|
||||
|
||||
r = requests.get(
|
||||
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_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
|
||||
# def test_etudiants():
|
||||
#
|
||||
# fields = [
|
||||
# "civilite",
|
||||
# "code_ine",
|
||||
# "code_nip",
|
||||
# "date_naissance",
|
||||
# "email",
|
||||
# "emailperso",
|
||||
# "etudid",
|
||||
# "nom",
|
||||
# "prenom",
|
||||
# "nomprenom",
|
||||
# "lieu_naissance",
|
||||
# "dept_naissance",
|
||||
# "nationalite",
|
||||
# "boursier",
|
||||
# "id",
|
||||
# "domicile",
|
||||
# "villedomicile",
|
||||
# "telephone",
|
||||
# "fax",
|
||||
# "description",
|
||||
# "codepostaldomicile",
|
||||
# "paysdomicile",
|
||||
# "telephonemobile",
|
||||
# "typeadresse",
|
||||
# ]
|
||||
#
|
||||
# r = requests.get(
|
||||
# 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_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
|
||||
@ -180,7 +180,8 @@ def test_etudiant(): # XXX TODO pour Seb
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 24
|
||||
@ -200,7 +201,8 @@ def test_etudiant(): # XXX TODO pour Seb
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 24
|
||||
@ -269,12 +271,12 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
||||
|
||||
assert fields_OK is True
|
||||
|
||||
|
||||
######### Test code nip #########
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestres",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
@ -294,7 +296,8 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestres",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
@ -311,89 +314,89 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
||||
assert fields_OK is True
|
||||
|
||||
|
||||
#etudiant_bulletin_semestre
|
||||
# etudiant_bulletin_semestre
|
||||
def test_etudiant_bulletin_semestre():
|
||||
|
||||
fields = [
|
||||
"etudid",
|
||||
"formsemestre_id",
|
||||
"date",
|
||||
"publie",
|
||||
"etapes",
|
||||
"etudiant",
|
||||
"note",
|
||||
"rang",
|
||||
"rang_group",
|
||||
"note_max",
|
||||
"bonus_sport_culture",
|
||||
"ue",
|
||||
"ue_capitalisee",
|
||||
"absences",
|
||||
"appreciation",
|
||||
]
|
||||
# fields = [
|
||||
# "etudid",
|
||||
# "formsemestre_id",
|
||||
# "date",
|
||||
# "publie",
|
||||
# "etapes",
|
||||
# "etudiant",
|
||||
# "note",
|
||||
# "rang",
|
||||
# "rang_group",
|
||||
# "note_max",
|
||||
# "bonus_sport_culture",
|
||||
# "ue",
|
||||
# "ue_capitalisee",
|
||||
# "absences",
|
||||
# "appreciation",
|
||||
# ]
|
||||
|
||||
######### Test etudid #########
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/etudid/1/formsemestre/1/bulletin",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 15
|
||||
|
||||
bulletin = r.json()
|
||||
|
||||
fields_OK = True
|
||||
|
||||
# Vérifie si tous les champs sont bien présents
|
||||
for field in bulletin:
|
||||
if field not in fields:
|
||||
fields_OK = False
|
||||
|
||||
assert fields_OK is True
|
||||
assert len(r.json()) == 13
|
||||
|
||||
# bulletin = r.json()
|
||||
#
|
||||
# fields_OK = True
|
||||
#
|
||||
# # Vérifie si tous les champs sont bien présents
|
||||
# for field in bulletin:
|
||||
# if field not in fields:
|
||||
# fields_OK = False
|
||||
#
|
||||
# assert fields_OK is True
|
||||
|
||||
######### Test code nip #########
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/formsemestre/1/bulletin",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 15
|
||||
|
||||
bulletin = r.json()
|
||||
|
||||
fields_OK = True
|
||||
|
||||
# Vérifie si tous les champs sont bien présents
|
||||
for field in bulletin:
|
||||
if field not in fields:
|
||||
fields_OK = False
|
||||
|
||||
assert fields_OK is True
|
||||
assert len(r.json()) == 13
|
||||
|
||||
# bulletin = r.json()
|
||||
#
|
||||
# fields_OK = True
|
||||
#
|
||||
# # Vérifie si tous les champs sont bien présents
|
||||
# for field in bulletin:
|
||||
# if field not in fields:
|
||||
# fields_OK = False
|
||||
#
|
||||
# assert fields_OK is True
|
||||
|
||||
######### Test code ine #########
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/formsemestre/1/bulletin",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 15
|
||||
|
||||
bulletin = r.json()
|
||||
|
||||
fields_OK = True
|
||||
|
||||
# Vérifie si tous les champs sont bien présents
|
||||
for field in bulletin:
|
||||
if field not in fields:
|
||||
fields_OK = False
|
||||
|
||||
assert fields_OK is True
|
||||
assert len(r.json()) == 13
|
||||
|
||||
# bulletin = r.json()
|
||||
#
|
||||
# fields_OK = True
|
||||
#
|
||||
# # Vérifie si tous les champs sont bien présents
|
||||
# for field in bulletin:
|
||||
# if field not in fields:
|
||||
# fields_OK = False
|
||||
#
|
||||
# assert fields_OK is True
|
||||
|
||||
|
||||
# etudiant_groups
|
||||
@ -411,7 +414,6 @@ def test_etudiant_groups():
|
||||
"group_name",
|
||||
]
|
||||
|
||||
|
||||
######### Test etudid #########
|
||||
|
||||
r = requests.get(
|
||||
@ -433,13 +435,12 @@ def test_etudiant_groups():
|
||||
|
||||
assert fields_OK is True
|
||||
|
||||
|
||||
|
||||
######### Test code nip #########
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/nip/1/semestre/1/groups",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
@ -459,7 +460,8 @@ def test_etudiant_groups():
|
||||
|
||||
r = requests.get(
|
||||
SCODOC_URL + "/ScoDoc/api/etudiant/ine/1/semestre/1/groups",
|
||||
headers=HEADERS, verify=CHECK_CERTIFICATE
|
||||
headers=HEADERS,
|
||||
verify=CHECK_CERTIFICATE,
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert len(r.json()) == 1
|
||||
|
Loading…
Reference in New Issue
Block a user