1
0
forked from ScoDoc/ScoDoc

Merge branch 'new_api' of https://scodoc.org/git/leonard.montalbano/ScoDoc into new_api_leonard

This commit is contained in:
Emmanuel Viennet 2022-07-19 10:38:08 +02:00
commit 455ce295d8
24 changed files with 3516 additions and 416 deletions

View File

@ -31,3 +31,4 @@ from app.api import evaluations
from app.api import jury
from app.api import absences
from app.api import logos
from app.api import debug

View File

@ -5,10 +5,12 @@ from flask import jsonify
from app.api import bp
from app.api.errors import error_response
from app.api.auth import token_auth, token_permission_required
from app.models import Identite
from app.models import Identite, FormSemestre
from app.scodoc import notesdb as ndb
from app.scodoc import sco_abs
from app.scodoc.sco_abs import list_abs_date, annule_absence, annule_justif, add_abslist
from app.scodoc.sco_groups import get_group_members
from app.scodoc.sco_permissions import Permission
@ -106,40 +108,155 @@ def absences_just(etudid: int = None):
return jsonify(abs_just)
# XXX TODO INACHEVEE
# @bp.route(
# "/absences/abs_group_etat/<int:group_id>",
# methods=["GET"],
# )
# @bp.route(
# "/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
# methods=["GET"],
# )
# @token_auth.login_required
# @token_permission_required(Permission.APIView)
# def abs_groupe_etat( # XXX A REVOIR XXX
# group_id: int, date_debut, date_fin, with_boursier=True, format="html"
# ):
# """
# Liste des absences d'un ou plusieurs groupes entre deux dates
# """
# return error_response(501, message="Not implemented")
@bp.route(
"/absences/abs_group_etat/<int:group_id>",
methods=["GET"],
)
@bp.route(
"/absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>",
methods=["GET"],
)
@token_auth.login_required
@token_permission_required(Permission.APIView)
def abs_groupe_etat(group_id: int, date_debut=None, date_fin=None):
"""
Liste des absences d'un groupe (possibilité de choisir entre deux dates)
# # Fonction utilisée : app.scodoc.sco_groups.get_group_members() et app.scodoc.sco_abs.list_abs_date()
group_id = l'id du groupe
date_debut = None par défaut, sinon la date ISO du début de notre filtre
date_fin = None par défaut, sinon la date ISO de la fin de notre filtre
# try:
# # Utilisation de la fonction get_group_members
# members = get_group_members(group_id)
# except ValueError:
# return error_response(
# 404, message="La requête ne peut être traitée en létat actuel"
# )
Exemple de résultat :
[
{
"etudid": 1,
"list_abs": []
},
{
"etudid": 2,
"list_abs": [
{
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
"matin": true,
"estabs": true,
"estjust": true,
"description": "",
"begin": "2022-04-15 08:00:00",
"end": "2022-04-15 11:59:59"
},
{
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
"matin": false,
"estabs": true,
"estjust": false,
"description": "",
"begin": "2022-04-15 12:00:00",
"end": "2022-04-15 17:59:59"
},
]
},
...
]
"""
# Fonction utilisée : app.scodoc.sco_groups.get_group_members() et app.scodoc.sco_abs.list_abs_date()
# data = []
# # Filtre entre les deux dates renseignées
# for member in members:
# abs = sco_abs.list_abs_date(member.id, date_debut, date_fin)
# data.append(abs)
# Utilisation de la fonction get_group_members
members = get_group_members(group_id)
# # return jsonify(data) # XXX TODO faire en sorte de pouvoir renvoyer sa (ex to_dict() dans absences)
# return error_response(501, message="Not implemented")
data = []
# Filtre entre les deux dates renseignées
for member in members:
abs = {
"etudid": member["etudid"],
"list_abs": sco_abs.list_abs_date(member["etudid"], date_debut, date_fin),
}
data.append(abs)
return jsonify(data)
@bp.route(
"/absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs",
methods=["POST"],
defaults={"just_or_not": 0},
)
@bp.route(
"/absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs/only_not_just",
methods=["POST"],
defaults={"just_or_not": 1},
)
@bp.route(
"/absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs/only_just",
methods=["POST"],
defaults={"just_or_not": 2},
)
@token_auth.login_required
@token_permission_required(Permission.APIAbsChange)
def reset_etud_abs(etudid: int, list_abs, just_or_not: int = 0):
"""
Set la liste des absences d'un étudiant sur tout un semestre.
(les absences existant pour cet étudiant sur cette période sont effacées)
etudid : l'id d'un étudiant
list_abs : json d'absences
just_or_not : 0 (pour les absences justifiées et non justifiées),
1 (pour les absences justifiées),
2 (pour les absences non justifiées)
"""
# Toutes les absences
if just_or_not == 0:
# suppression des absences et justificatif déjà existant pour éviter les doublons
for abs in list_abs:
# Récupération de la date au format iso
jour = abs["jour"].isoformat()
if abs["matin"] is True:
annule_absence(etudid, jour, True)
annule_justif(etudid, jour, True)
else:
annule_absence(etudid, jour, False)
annule_justif(etudid, jour, False)
# Ajout de la liste d'absences en base
add_abslist(list_abs)
# Uniquement les absences justifiées
elif just_or_not == 1:
list_abs_not_just = []
# Trie des absences justifiées
for abs in list_abs:
if abs["estjust"] is False:
list_abs_not_just.append(abs)
# suppression des absences et justificatif déjà existant pour éviter les doublons
for abs in list_abs:
# Récupération de la date au format iso
jour = abs["jour"].isoformat()
if abs["matin"] is True:
annule_absence(etudid, jour, True)
annule_justif(etudid, jour, True)
else:
annule_absence(etudid, jour, False)
annule_justif(etudid, jour, False)
# Ajout de la liste d'absences en base
add_abslist(list_abs_not_just)
# Uniquement les absences non justifiées
elif just_or_not == 2:
list_abs_just = []
# Trie des absences non justifiées
for abs in list_abs:
if abs["estjust"] is True:
list_abs_just.append(abs)
# suppression des absences et justificatif déjà existant pour éviter les doublons
for abs in list_abs:
# Récupération de la date au format iso
jour = abs["jour"].isoformat()
if abs["matin"] is True:
annule_absence(etudid, jour, True)
annule_justif(etudid, jour, True)
else:
annule_absence(etudid, jour, False)
annule_justif(etudid, jour, False)
# Ajout de la liste d'absences en base
add_abslist(list_abs_just)

31
app/api/debug.py Normal file
View File

@ -0,0 +1,31 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Gestion scolarite IUT
#
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Emmanuel Viennet emmanuel.viennet@viennet.net
#
##############################################################################
"""
!!! ATTENTION !!!
Fichier a utilisé uniquement à des fins de debug
"""

View File

@ -8,23 +8,25 @@
API : accès aux étudiants
"""
from flask import jsonify
from flask import jsonify, make_response
import app
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_last_instance_etud_from_etudid_or_nip_or_ine
from app.models import Departement, FormSemestreInscription, FormSemestre, Identite
from app.scodoc import sco_bulletins
from app.scodoc import sco_groups
from app.scodoc.sco_bulletins import do_formsemestre_bulletinetud
from app.scodoc.sco_permissions import Permission
@bp.route("/etudiants/courant", defaults={"long": False})
@bp.route("/etudiants/courant/long", defaults={"long": True})
@bp.route("/etudiants/courants", defaults={"long": False})
@bp.route("/etudiants/courants/long", defaults={"long": True})
@token_auth.login_required
@token_permission_required(Permission.APIView)
def etudiants_courant(long=False):
def etudiants_courants(long=False):
"""
Liste des étudiants inscrits dans un formsemestre actuellement en cours.
@ -104,27 +106,7 @@ def etudiant(etudid: int = None, nip: str = None, ine: str = None):
"description": ""
}
"""
if etudid is not None:
etud = Identite.query.get(etudid)
else:
if nip is not None:
query = Identite.query.filter_by(code_nip=nip)
elif ine is not None:
query = Identite.query.filter_by(code_ine=ine)
else:
return error_response(
404,
message="parametre manquant",
)
if query.count() > 1: # cas rare d'un étudiant présent dans plusieurs depts
etuds = []
for e in query:
admission = e.admission.first()
etuds.append((((admission.annee or 0) if admission else 0), e))
etuds.sort()
etud = etuds[-1][1]
else:
etud = query.first()
etud = get_last_instance_etud_from_etudid_or_nip_or_ine(etudid, nip, ine)
if etud is None:
return error_response(
@ -238,41 +220,74 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
@bp.route(
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin",
methods=["GET"],
defaults={"version": "long"},
defaults={"version": "long", "pdf": False},
)
@bp.route(
"/etudiant/nip/<string:nip>/formsemestre/<int:formsemestre_id>/bulletin",
methods=["GET"],
defaults={"version": "long"},
defaults={"version": "long", "pdf": False},
)
@bp.route(
"/etudiant/ine/<string:ine>/formsemestre/<int:formsemestre_id>/bulletin",
methods=["GET"],
defaults={"version": "long"},
defaults={"version": "long", "pdf": False},
)
# Version PDF non fonctionnelle
@bp.route(
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
methods=["GET"],
defaults={"version": "long", "pdf": True},
)
# @bp.route(
# "/etudiant/nip/<string:nip>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
# methods=["GET"],
# defaults={"version": "long", "pdf": True},
# )
# @bp.route(
# "/etudiant/ine/<string:ine>/formsemestre/<int:formsemestre_id>/bulletin/pdf",
# methods=["GET"],
# defaults={"version": "long", "pdf": True},
# )
@bp.route(
"/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/short",
methods=["GET"],
defaults={"version": "short"},
defaults={"version": "short", "pdf": False},
)
@bp.route(
"/etudiant/nip/<string:nip>/formsemestre/<int:formsemestre_id>/bulletin/short",
methods=["GET"],
defaults={"version": "short"},
defaults={"version": "short", "pdf": False},
)
@bp.route(
"/etudiant/ine/<string:ine>/formsemestre/<int:formsemestre_id>/bulletin/short",
methods=["GET"],
defaults={"version": "short"},
defaults={"version": "short", "pdf": False},
)
# Version PDF non fonctionnelle
# @bp.route(
# "/etudiant/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/bulletin/short/pdf",
# methods=["GET"],
# defaults={"version": "short", "pdf": True},
# )
# @bp.route(
# "/etudiant/nip/<string:nip>/formsemestre/<int:formsemestre_id>/bulletin/short/pdf",
# methods=["GET"],
# defaults={"version": "short", "pdf": True},
# )
# @bp.route(
# "/etudiant/ine/<string:ine>/formsemestre/<int:formsemestre_id>/bulletin/short/pdf",
# methods=["GET"],
# defaults={"version": "short", "pdf": True},
# )
@token_auth.login_required
@token_permission_required(Permission.APIView)
def etudiant_bulletin_semestre(
def etudiant_bulletin_semestre( # XXX TODO Ajouter la possibilité de retourner en version pdf
formsemestre_id,
etudid: int = None,
nip: str = None,
ine: str = None,
version="long",
pdf: bool = False,
):
"""
Retourne le bulletin d'un étudiant en fonction de son id et d'un semestre donné
@ -449,6 +464,14 @@ def etudiant_bulletin_semestre(
)
app.set_sco_dept(dept.acronym)
if pdf:
response = make_response(
do_formsemestre_bulletinetud(formsemestre, etudid, version, "pdf")
)
response.headers["Content-Type"] = "application/json"
return response
return sco_bulletins.get_formsemestre_bulletin_etud_json(
formsemestre, etud, version=version
)

View File

@ -8,6 +8,7 @@ from app.models import Evaluation
from app.api import bp
from app.api.auth import token_auth, token_permission_required
from app.api.errors import error_response
from app.models import Evaluation
from app.scodoc.sco_evaluation_db import do_evaluation_get_all_notes
from app.scodoc.sco_permissions import Permission

View File

@ -10,13 +10,29 @@ from app.models.formations import Formation
from app.scodoc import sco_formations
from app.scodoc.sco_permissions import Permission
@bp.route("/formations", methods=["GET"])
@token_auth.login_required
@token_permission_required(Permission.APIView)
def formations():
"""
Retourne la liste de toutes les formations (tous départements)
Exemple de résultat :
"""
# Récupération de toutes les formations
list_formations = models.Formation.query.all()
# Mise en forme des données
data = [d.to_dict() for d in list_formations]
return jsonify(data)
@bp.route("/formations_ids", methods=["GET"])
@token_auth.login_required
@token_permission_required(Permission.APIView)
def formations_ids():
"""
Retourne la liste de toutes les formations (tous départements)
Retourne la liste de toutes les id de formations (tous départements)
Exemple de résultat : [ 17, 99, 32 ]
"""
@ -79,6 +95,7 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False):
Retourne la formation, avec UE, matières, modules
formation_id : l'id d'une formation
export_ids : True ou False, si l'on veut ou non exporter les ids
Exemple de résultat :
{
@ -233,6 +250,7 @@ def moduleimpl(moduleimpl_id: int):
def referentiel_competences(formation_id: int):
"""
Retourne le référentiel de compétences
formation_id : l'id d'une formation
return json, ou null si pas de référentiel associé.

View File

@ -1,14 +1,22 @@
########################################## Formsemestres ##############################################################
import statistics
from flask import jsonify
import app
from app import models
from app.api import bp
from app.api.auth import token_auth, token_permission_required
from app.models import Departement, FormSemestre, FormSemestreEtape
from app.api.errors import error_response
from app.comp import res_sem
from app.comp.moy_mod import ModuleImplResults
from app.comp.res_compat import NotesTableCompat
from app.models import Departement, FormSemestre, FormSemestreEtape, ModuleImpl
from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json
from app.scodoc.sco_groups import get_etud_groups
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_utils import ModuleType
import app.scodoc.sco_utils as scu
@bp.route("/formsemestre/<int:formsemestre_id>", methods=["GET"])
@ -415,3 +423,208 @@ def formsemestre_programme(formsemestre_id: int):
"modules": m_list[ModuleType.STANDARD],
}
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/etudiants",
methods=["GET"],
defaults={"etat": "I"},
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires",
methods=["GET"],
defaults={"etat": "D"},
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/etudiants/defaillants",
methods=["GET"],
defaults={"etat": "DEF"},
)
@token_auth.login_required
@token_permission_required(Permission.APIView)
def formsemestre_etudiants(formsemestre_id: int, etat: str):
"""
Retourne la liste des étudiants d'un semestre
formsemestre_id : l'id d'un semestre
"""
# fonction to use : sco_groups.get_etud_groups
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
# Récupération des étudiants du formsemestre
etuds = [etu.to_dict_short() for etu in formsemestre.etuds]
res = []
# Trie des étudiants suivant leur état d'inscription voulu
for etu in etuds:
formsemestre_inscription = models.FormSemestreInscription.query.filter_by(
formsemestre_id=formsemestre_id, etudid=etu["id"]
).first_or_404()
if formsemestre_inscription.etat == etat:
res.append(etu)
# Ajout des groups de chaques étudiants
for etu in res:
etu["groups"] = get_etud_groups(etu["id"], formsemestre_id)
return jsonify(res)
@bp.route("/formsemestre/<int:formsemestre_id>/etat_evals", methods=["GET"])
@token_auth.login_required
@token_permission_required(Permission.APIView)
def etat_evals(formsemestre_id: int):
"""
Retourne les informations sur l'état des évaluations d'un semestre donnée
formsemestre_id : l'id d'un semestre
Exemple de résultat :
{
"RT1.1": [
{
"id": 1,
"titre": "Initiation aux réseaux informatiques",
"evaluations": [
{
"id": 1,
"description": null,
"datetime_epreuve": null,
"heure_fin": "09:00:00",
"coefficient": "02.00"
"comptee": "oui",
"inscrits": 16,
"manquantes": 0,
"ABS": 0,
"ATT": 0,
"EXC": 0,
"saisie_notes": {
"datetime_debut": "2021-09-11T00:00:00+02:00",
"datetime_fin": "2022-08-25T00:00:00+02:00",
"datetime_mediane": "2022-03-19T00:00:00+01:00"
}
},
{
"id": 22,
"description": null,
"datetime_epreuve": "Tue, 31 May 2022 00:00:00 GMT",
"heure_fin": "08:00:00",
"comptee": "oui",
"inscrits": 16,
"manquantes": 0,
"ABS": 0,
"ATT": 0,
"EXC": 0,
"saisie_notes": {
"datetime_debut": "2021-09-11T00:00:00+02:00",
"datetime_fin": "2022-08-25T00:00:00+02:00",
"datetime_mediane": "2022-03-19T00:00:00+01:00"
}
},
]
},
]
}
"""
# Récupération du semestre
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
# Set du dept
dept = Departement.query.get(formsemestre.dept_id)
app.set_sco_dept(dept.acronym)
# Récupération des Ues
list_ues = formsemestre.query_ues()
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
ues = {}
for ue in list_ues:
modules = []
mods = ue.modules
for mod in mods:
dict_module = {}
moduleimpl = ModuleImpl.query.get_or_404(mod.id)
modimpl_results: ModuleImplResults = nt.modimpls_results[moduleimpl.id]
dict_module["id"] = mod.id
dict_module["titre"] = mod.titre
list_eval = []
for evaluation in moduleimpl.evaluations:
eval_etat = modimpl_results.evaluations_etat[evaluation.id]
eval = {}
eval["id"] = evaluation.id
eval["description"] = evaluation.description
eval["datetime_epreuve"] = (
evaluation.jour.isoformat() if evaluation.jour is not None else None
)
eval["heure_fin"] = evaluation.heure_fin.isoformat()
eval["coefficient"] = evaluation.coefficient
eval["comptee"] = "oui" if eval_etat.is_complete else "non"
eval["inscrits"] = modimpl_results.nb_inscrits_module
eval["manquantes"] = len(
modimpl_results.evals_etudids_sans_note[evaluation.id]
)
eval["ABS"] = sum(
modimpl_results.evals_notes[evaluation.id] == scu.NOTES_ABSENCE
)
eval["ATT"] = eval_etat.nb_attente
eval["EXC"] = sum(
modimpl_results.evals_notes[evaluation.id] == scu.NOTES_NEUTRALISE
)
# Récupération de toutes les notes de l'évaluation
notes = models.NotesNotes.query.filter_by(
evaluation_id=evaluation.id
).all()
date_debut = None
date_fin = None
date_mediane = None
# Si il y a plus d'une note saisie pour l'évaluation
if len(notes) >= 1:
# Trie des notes en fonction de leurs dates
notes_sorted = sorted(notes, key=lambda note: note.date)
date_debut = notes_sorted[0].date
date_fin = notes_sorted[-1].date
# Récupération de l'id de la note médiane
list_id_notes_sorted = [note.id for note in notes_sorted]
# Ici si la longueur est paire on prend, on prend le +1 car un indice ne peux pas avoir de nombre floatant
id_mediane = list_id_notes_sorted[
int((len(list_id_notes_sorted)) / 2)
]
for n in notes_sorted:
if n.id == id_mediane:
date_mediane = n.date
eval["saisie_notes"] = {
"datetime_debut": date_debut.isoformat()
if date_debut is not None
else None,
"datetime_fin": date_fin.isoformat()
if date_fin is not None
else None,
"datetime_mediane": date_mediane.isoformat()
if date_mediane is not None
else None,
}
list_eval.append(eval)
dict_module["evaluations"] = list_eval
modules.append(dict_module)
ues[ue.acronyme] = modules
return jsonify(ues)

View File

@ -52,8 +52,8 @@ def partition(formsemestre_id: int):
return jsonify(data)
@bp.route("/partitions/groups/<int:group_id>", methods=["GET"])
@bp.route("/partitions/groups/<int:group_id>/etat/<string:etat>", methods=["GET"])
@bp.route("/partition/group/<int:group_id>", methods=["GET"])
@bp.route("/partition/group/<int:group_id>/etat/<string:etat>", methods=["GET"])
@token_auth.login_required
@token_permission_required(Permission.APIView)
def etud_in_group(group_id: int, etat=None):

View File

@ -1,11 +1,14 @@
from app import models
from app.api.errors import error_response
from app.models import Identite
def get_etud_from_etudid_or_nip_or_ine(
def get_last_instance_etud_from_etudid_or_nip_or_ine(
etudid=None, nip=None, ine=None
) -> models.Identite:
"""
etudiant en fonction de l'etudid, code nip et code ine rentré en paramètres
Retourne l'instance de l'etudiant la plus récente en fonction de l'etudid, code nip et code ine rentré en paramètres
etudid : None ou un int etudid
nip : None ou un int code_nip
@ -13,12 +16,27 @@ def get_etud_from_etudid_or_nip_or_ine(
Return None si étudiant inexistant.
"""
if etudid is None:
if nip is None: # si ine
etud = models.Identite.query.filter_by(code_ine=str(ine)).first()
else: # si nip
etud = models.Identite.query.filter_by(code_nip=str(nip)).first()
else: # si etudid
etud = models.Identite.query.filter_by(id=etudid).first()
if etudid is not None:
etud = Identite.query.get(etudid)
else:
if nip is not None:
query = Identite.query.filter_by(code_nip=nip)
elif ine is not None:
query = Identite.query.filter_by(code_ine=ine)
else:
return error_response(
404,
message="parametre manquant",
)
if query.count() > 1: # cas rare d'un étudiant présent dans plusieurs depts
etuds = []
for e in query:
admission = e.admission.first()
etuds.append((((admission.annee or 0) if admission else 0), e))
etuds.sort()
etud = etuds[-1][1]
else:
etud = query.first()
return etud

View File

@ -29,6 +29,15 @@ class Absence(db.Model):
# XXX TODO: contrainte ajoutée: vérifier suppression du module
# (mettre à NULL sans supprimer)
def __init__(self, id, etudid, jour, estabs, estjust, matin, description):
self.id = id
self.etudid = etudid
self.jour = jour
self.estabs = estabs
self.estjust = estjust
self.matin = matin
self.description = description
def to_dict(self):
data = {
"id": self.id,

View File

@ -83,6 +83,40 @@ class ApcReferentielCompetences(db.Model, XMLModel):
)
formations = db.relationship("Formation", backref="referentiel_competence")
def __init__(
self,
id,
dept_id,
annexe,
specialite,
specialite_long,
type_titre,
type_structure,
type_departement,
version_orebut,
_xml_attribs,
#scodoc_date_loaded,
scodoc_orig_filename,
# competences,
# parcours,
# formations,
):
self.id = id
self.dept_id = dept_id
self.annexe = annexe
self.specialite = specialite
self.specialite_long = specialite_long
self.type_titre = type_titre
self.type_structure = type_structure
self.type_departement = type_departement
self.version_orebut = version_orebut
self._xml_attribs = _xml_attribs
#self.scodoc_date_loaded = scodoc_date_loaded
self.scodoc_orig_filename = scodoc_orig_filename
# self.competences = competences
# self.parcours = parcours
# self.formations = formations
def __repr__(self):
return f"<ApcReferentielCompetences {self.id} {self.specialite!r} {self.departement!r}>"
@ -191,6 +225,32 @@ class ApcCompetence(db.Model, XMLModel):
cascade="all, delete-orphan",
)
def __init__(
self,
id,
referentiel_id,
id_orebut,
titre,
titre_long,
couleur,
numero,
_xml_attribs,
situations,
composantes_essentielles,
niveaux,
):
self.id = id
self.referentiel_id = referentiel_id
self.id_orebut = id_orebut
self.titre = titre
self.titre_long = titre_long
self.couleur = couleur
self.numero = numero
self._xml_attribs = _xml_attribs
self.situations = situations
self.composantes_essentielles = composantes_essentielles
self.niveaux = niveaux
def __repr__(self):
return f"<ApcCompetence {self.id} {self.titre!r}>"
@ -228,6 +288,12 @@ class ApcSituationPro(db.Model, XMLModel):
)
libelle = db.Column(db.Text(), nullable=False)
# aucun attribut (le text devient le libellé)
def __init__(self, id, competence_id, libelle):
self.id = id
self.competence_id = competence_id
self.libelle = libelle
def to_dict(self):
return {"libelle": self.libelle}
@ -240,6 +306,11 @@ class ApcComposanteEssentielle(db.Model, XMLModel):
)
libelle = db.Column(db.Text(), nullable=False)
def __init__(self, id, competence_id, libelle):
self.id = id
self.competence_id = competence_id
self.libelle = libelle
def to_dict(self):
return {"libelle": self.libelle}
@ -268,6 +339,14 @@ class ApcNiveau(db.Model, XMLModel):
)
ues = db.relationship("UniteEns", back_populates="niveau_competence")
def __init__(self, id, competence_id, libelle, annee, ordre, app_critiques):
self.id = id
self.competence_id = competence_id
self.libelle = libelle
self.annee = annee
self.ordre = ordre
self.app_critiques = app_critiques
def __repr__(self):
return f"""<{self.__class__.__name__} {self.id} ordre={self.ordre!r} annee={
self.annee!r} {self.competence!r}>"""
@ -373,6 +452,13 @@ class ApcAppCritique(db.Model, XMLModel):
query = query.filter(ApcNiveau.competence == competence)
return query
def __init__(self, id, niveau_id, code, libelle, modules):
self.id = id
self.niveau_id = niveau_id
self.code = code
self.libelle = libelle
self.modules = modules
def to_dict(self) -> dict:
return {"libelle": self.libelle}
@ -431,6 +517,14 @@ class ApcParcours(db.Model, XMLModel):
cascade="all, delete-orphan",
)
def __init__(self, id, referentiel_id, numero, code, libelle, annes):
self.id = id
self.referentiel_id = referentiel_id
self.numero = numero
self.code = code
self.libelle = libelle
self.annes = annes
def __repr__(self):
return f"<{self.__class__.__name__} {self.id} {self.code!r} ref={self.referentiel}>"
@ -451,6 +545,11 @@ class ApcAnneeParcours(db.Model, XMLModel):
ordre = db.Column(db.Integer)
"numéro de l'année: 1, 2, 3"
def __init__(self, id, parcours_id, ordre):
self.id = id
self.parcours_id = parcours_id
self.ordre = ordre
def __repr__(self):
return f"<{self.__class__.__name__} {self.id} ordre={self.ordre!r} parcours={self.parcours.code!r}>"

View File

@ -164,6 +164,28 @@ class FormSemestre(db.Model):
d["parcours"] = [p.to_dict() for p in self.parcours]
return d
def to_dict_api(self):
"""
Un dict avec les informations sur le semestre destiné à l'api
"""
d = dict(self.__dict__)
d.pop("_sa_instance_state", None)
d["formsemestre_id"] = self.id
d["titre_num"] = self.titre_num()
if self.date_debut:
d["date_debut"] = self.date_debut.strftime("%d/%m/%Y")
d["date_debut_iso"] = self.date_debut.isoformat()
else:
d["date_debut"] = d["date_debut_iso"] = ""
if self.date_fin:
d["date_fin"] = self.date_fin.strftime("%d/%m/%Y")
d["date_fin_iso"] = self.date_fin.isoformat()
else:
d["date_fin"] = d["date_fin_iso"] = ""
d["responsables"] = [u.id for u in self.responsables]
d["titre_court"] = self.formation.acronyme
return d
def get_infos_dict(self) -> dict:
"""Un dict avec des informations sur le semestre
pour les bulletins et autres templates
@ -632,6 +654,11 @@ class FormSemestreEtape(db.Model):
# etape_apo aurait du etre not null, mais oublié
etape_apo = db.Column(db.String(APO_CODE_STR_LEN), index=True)
def __init__(self, id, formsemestre_id, etape_apo):
self.id = id
self.formsemestre_id = formsemestre_id
self.etape_apo = etape_apo
def __bool__(self):
"Etape False if code empty"
return self.etape_apo is not None and (len(self.etape_apo) > 0)

View File

@ -47,6 +47,25 @@ class NotesNotes(db.Model):
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
uid = db.Column(db.Integer, db.ForeignKey("user.id"))
def __init__(self, etudid, evaluation_id, value, comment, date, uid):
self.etudid = etudid
self.evaluation_id = evaluation_id
self.value = value
self.comment = comment
self.date = date
self.uid = uid
def to_dict(self):
return {
"id": self.id,
"etudid": self.etudid,
"evaluation_id": self.evaluation_id,
"value": self.value,
"comment": self.comment,
"date": self.date,
"uid": self.uid,
}
class NotesNotesLog(db.Model):
"""Historique des modifs sur notes (anciennes entrees de notes_notes)"""

View File

@ -21,13 +21,22 @@ import requests
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
# Etudiant pour les tests
from tests.api.tools_test_api import (
verify_fields,
ABSENCES_FIELDS,
ABSENCES_GROUP_ETAT_FIELDS,
)
ETUDID = 1
# absences
def test_absences(api_headers):
"""
Route: /absences/etudid/<int:etudid>
Test 'absences'
Route :
- /absences/etudid/<int:etudid>
"""
r = requests.get(
f"{API_URL}/absences/etudid/{ETUDID}",
@ -35,29 +44,165 @@ def test_absences(api_headers):
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
absences = r.json()
assert isinstance(absences, list)
for abs in absences:
assert verify_fields(abs, ABSENCES_FIELDS) is True
assert isinstance(abs["jour"], str)
assert isinstance(abs["matin"], bool)
assert isinstance(abs["estabs"], bool)
assert isinstance(abs["estjust"], bool)
assert isinstance(abs["description"], str)
assert isinstance(abs["begin"], str)
assert isinstance(abs["end"], str)
assert abs["begin"] < abs["end"]
# absences_justify
def test_absences_justify(api_headers):
"""
Route: /absences/etudid/<etudid:int>/just
Test 'absences_just'
Route :
- /absences/etudid/<int:etudid>/just
"""
r = requests.get(
API_URL + f"/absences/etudid/{ETUDID}/just",
f"{API_URL}/absences/etudid/{ETUDID}/just",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# TODO vérifier résultat
absences = r.json()
assert isinstance(absences, list)
for abs in absences:
assert verify_fields(abs, ABSENCES_FIELDS) is True
assert isinstance(abs["jour"], str)
assert isinstance(abs["matin"], bool)
assert isinstance(abs["estabs"], bool)
assert isinstance(abs["estjust"], bool)
assert isinstance(abs["description"], str)
assert isinstance(abs["begin"], str)
assert isinstance(abs["end"], str)
assert abs["begin"] < abs["end"]
def test_abs_groupe_etat(api_headers):
"""
Test 'abs_groupe_etat'
Routes :
- /absences/abs_group_etat/<int:group_id>
- /absences/abs_group_etat/group_id/<int:group_id>/date_debut/<string:date_debut>/date_fin/<string:date_fin>
"""
group_id = 1
r = requests.get(
f"{API_URL}/absences/abs_group_etat/{group_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
list_absences = r.json()
assert isinstance(list_absences, list)
list_id_etu = []
for etu in list_absences:
list_id_etu.append(etu["etudid"])
assert verify_fields(etu, ABSENCES_GROUP_ETAT_FIELDS) is True
assert isinstance(etu["etudid"], int)
assert isinstance(etu["list_abs"], list)
list_abs = etu["list_abs"]
for abs in list_abs:
assert verify_fields(abs, ABSENCES_FIELDS) is True
assert isinstance(abs["jour"], str)
assert isinstance(abs["matin"], bool)
assert isinstance(abs["estabs"], bool)
assert isinstance(abs["estjust"], bool)
assert isinstance(abs["description"], str)
assert isinstance(abs["begin"], str)
assert isinstance(abs["end"], str)
assert abs["begin"] < abs["end"]
all_unique = True
for id in list_id_etu:
if list_id_etu.count(id) > 1:
all_unique = False
assert all_unique is True
date_debut = "Fri, 15 Apr 2021 00:00:00 GMT"
date_fin = "Fri, 18 Apr 2022 00:00:00 GMT"
r1 = requests.get(
f"{API_URL}/absences/abs_group_etat/group_id/{group_id}/date_debut/{date_debut}/date_fin/{date_fin}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r1.status_code == 200
list_absences1 = r.json()
assert isinstance(list_absences1, list)
list_id_etu1 = []
for etu in list_absences1:
list_id_etu1.append(etu["etudid"])
assert verify_fields(etu, ABSENCES_GROUP_ETAT_FIELDS) is True
assert isinstance(etu["etudid"], int)
assert isinstance(etu["list_abs"], list)
list_abs1 = etu["list_abs"]
for abs in list_abs1:
assert verify_fields(abs, ABSENCES_FIELDS) is True
assert isinstance(abs["jour"], str)
assert isinstance(abs["matin"], bool)
assert isinstance(abs["estabs"], bool)
assert isinstance(abs["estjust"], bool)
assert isinstance(abs["description"], str)
assert isinstance(abs["begin"], str)
assert isinstance(abs["end"], str)
assert abs["begin"] < abs["end"]
all_unique1 = True
for id in list_id_etu1:
if list_id_etu1.count(id) > 1:
all_unique1 = False
assert all_unique1 is True
# XXX TODO
# def test_abs_groupe_etat(api_headers):
# def reset_etud_abs(api_headers):
# """
# Route:
# Test 'reset_etud_abs'
#
# Routes :
# - /absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs
# - /absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs/only_not_just
# - /absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs/only_just
# """
# list_abs = []
# r = requests.get(
# API_URL + "/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# r_only_not_just = requests.get(
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs/only_not_just",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
#
# r_only_just = requests.get(
# f"{API_URL}/absences/etudid/{ETUDID}/list_abs/{list_abs}/reset_etud_abs/only_just",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )

View File

@ -19,29 +19,20 @@ Utilisation :
import requests
from tests.api.setup_test_api import (
API_URL,
CHECK_CERTIFICATE,
DEPT_ACRONYM,
api_headers,
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import (
verify_fields,
DEPARTEMENT_FIELDS,
FORMSEMESTRE_FIELDS,
verify_occurences_ids_etus,
)
from tests.api.tools_test_api import verify_fields
DEPARTEMENT_FIELDS = [
"id",
"acronym",
"description",
"visible",
"date_creation",
]
def test_departements(api_headers):
""" "
Routes: /departements_ids, /departement, /departement/<string:dept>/formsemestres_ids
"""
# --- Liste des ids
Routes: /departements_ids, /departement, /departement/<string:dept>/formsemestres_ids
"""
# --- departement_ids : liste des ids
r = requests.get(
API_URL + "/departements_ids",
headers=api_headers,
@ -53,8 +44,17 @@ def test_departements(api_headers):
assert len(departements_ids) > 0
assert all(isinstance(x, int) for x in departements_ids)
all_unique = True
for id in departements_ids:
if departements_ids.count(id) > 1:
all_unique = False
assert all_unique is True
dept_id = departements_ids[0]
# --- Infos sur un département, accès par id
# --- departement
# Infos sur un département, accès par id
r = requests.get(
f"{API_URL}/departement/{dept_id}",
headers=api_headers,
@ -62,8 +62,7 @@ def test_departements(api_headers):
)
assert r.status_code == 200
dept_a = r.json()
assert verify_fields(dept_a, DEPARTEMENT_FIELDS) is True
# --- Infos sur un département, accès par acronyme4
# Infos sur un département, accès par acronyme4
r = requests.get(
f"{API_URL}/departement/{dept_a['acronym']}",
headers=api_headers,
@ -71,65 +70,131 @@ def test_departements(api_headers):
)
assert r.status_code == 200
dept_b = r.json()
assert dept_a == dept_b
# Liste des formsemestres
assert dept_a == dept_b
assert verify_fields(dept_a, DEPARTEMENT_FIELDS) is True
assert isinstance(dept_a["id"], int)
assert isinstance(dept_a["acronym"], str)
assert dept_a["description"] is None or isinstance(dept_a["description"], str)
assert isinstance(dept_a["visible"], bool)
assert dept_a["date_creation"] is None or isinstance(dept_a["date_creation"], str)
# --- departements : Liste des départements
r = requests.get(
API_URL + "/departements",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# --- formsemestre_ids : listes des ids de formsemestres du département
r = requests.get(
f"{API_URL}/departement/{dept_a['acronym']}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
dept_ids = r.json()
assert isinstance(dept_ids, list)
assert all(isinstance(x, int) for x in dept_ids)
assert len(dept_ids) > 0
assert dept_id in dept_ids
dept_ids_a = r.json()
r = requests.get(
f"{API_URL}/departement/{dept_a['id']}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
dept_ids_b = r.json()
assert dept_ids_a == dept_ids_b
assert isinstance(dept_ids_a, list)
assert all(isinstance(id, int) for id in dept_ids_a)
assert len(dept_ids_a) > 0
assert dept_id in dept_ids_a
# Les erreurs
id_inexistant = 50000
r = requests.get(
f"{API_URL}/departement/{id_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
r = requests.get(
f"{API_URL}/departement/{id_inexistant}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
acronym_inexistant = "AAAAAAAAAAAAAAAAAAA"
r = requests.get(
f"{API_URL}/departement/{acronym_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
r = requests.get(
f"{API_URL}/departement/{acronym_inexistant}/formsemestres_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
def test_list_etudiants(api_headers):
fields = {"id", "nip", "ine", "nom", "nom_usuel", "prenom", "civilite"}
r = requests.get(
f"{API_URL}/departement/{DEPT_ACRONYM}/etudiants",
API_URL + "/departement/TAPI/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud = r.json()[0]
assert verify_fields(etud, fields) is True
etud_a = r.json()[0]
r = requests.get(
API_URL + "/departement/1/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud_b = r.json()[0]
assert etud_a == etud_b
assert verify_fields(etud_a, fields) is True
assert isinstance(etud_a["id"], int)
assert etud_a["nip"] is None or isinstance(etud_a["nip"], str)
assert etud_a["ine"] is None or isinstance(etud_a["ine"], str)
assert etud_a["nom"] is None or isinstance(etud_a["nom"], str)
assert etud_a["nom_usuel"] is None or isinstance(etud_a["nom_usuel"], str)
assert etud_a["prenom"] is None or isinstance(etud_a["prenom"], str)
assert isinstance(etud_a["civilite"], str)
assert len(etud_a["civilite"]) == 1
all_unique = verify_occurences_ids_etus(r.text)
assert all_unique is True
# Les erreurs
id_inexistant = 50000
r = requests.get(
f"{API_URL}/departement/{id_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
acronym_inexistant = "AAAAAAAAAAAAAAAAAAA"
r = requests.get(
f"{API_URL}/departement/{acronym_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
# liste_semestres_courant
def test_semestres_courant(api_headers):
fields = [
"titre",
"gestion_semestrielle",
"scodoc7_id",
"date_debut",
"bul_bgcolor",
"date_fin",
"resp_can_edit",
"dept_id",
"etat",
"resp_can_change_ens",
"id",
"modalite",
"ens_can_edit_eval",
"formation_id",
"gestion_compensation",
"elt_sem_apo",
"semestre_id",
"bul_hide_xml",
"elt_annee_apo",
"block_moyennes",
"formsemestre_id",
"titre_num",
"titre_formation",
"date_debut_iso",
"date_fin_iso",
"responsables",
]
dept_id = 1
r = requests.get(
f"{API_URL}/departement/{dept_id}",
@ -139,6 +204,7 @@ def test_semestres_courant(api_headers):
assert r.status_code == 200
dept = r.json()
assert dept["id"] == dept_id
# Accès via acronyme
r = requests.get(
f"{API_URL}/departement/{dept['acronym']}/formsemestres_courants",
@ -147,10 +213,6 @@ def test_semestres_courant(api_headers):
)
assert r.status_code == 200
result_a = r.json()
assert isinstance(result_a, list) # liste de formsemestres
assert len(result_a) > 0
sem = result_a[0]
assert verify_fields(sem, fields) is True
# accès via dept_id
r = requests.get(
@ -161,3 +223,7 @@ def test_semestres_courant(api_headers):
assert r.status_code == 200
result_b = r.json()
assert result_a == result_b
assert isinstance(result_a, list) # liste de formsemestres
assert len(result_a) > 0
sem = result_a[0]
assert verify_fields(sem, FORMSEMESTRE_FIELDS) is True

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Test API: accès aux étudiants
"""Test Logos
Utilisation :
créer les variables d'environnement: (indiquer les valeurs
@ -19,24 +19,54 @@ Utilisation :
import requests
from tests.api.setup_test_api import (
API_URL,
CHECK_CERTIFICATE,
DEPT_ACRONYM,
api_headers,
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import (
verify_fields,
verify_occurences_ids_etus,
BULLETIN_FIELDS,
BULLETIN_ETUDIANT_FIELDS,
BULLETIN_FORMATION_FIELDS,
BULLETIN_OPTIONS_FIELDS,
BULLETIN_RESSOURCES_FIELDS,
BULLETIN_SAES_FIELDS,
BULLETIN_UES_FIELDS,
BULLETIN_SEMESTRE_FIELDS,
BULLETIN_UES_RT11_RESSOURCES_FIELDS,
BULLETIN_UES_RT11_SAES_FIELDS,
BULLETIN_UES_RT21_RESSOURCES_FIELDS,
BULLETIN_UES_RT31_RESSOURCES_FIELDS,
BULLETIN_UES_RT21_SAES_FIELDS,
BULLETIN_UES_RT31_SAES_FIELDS,
BULLETIN_SEMESTRE_ABSENCES_FIELDS,
BULLETIN_SEMESTRE_ECTS_FIELDS,
BULLETIN_SEMESTRE_NOTES_FIELDS,
BULLETIN_SEMESTRE_RANG_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS,
BULLETIN_UES_UE_FIELDS,
BULLETIN_UES_UE_MOYENNE_FIELDS,
BULLETIN_UES_UE_RESSOURCES_RESSOURCE_FIELDS,
BULLETIN_UES_UE_SAES_SAE_FIELDS,
BULLETIN_UES_UE_ECTS_FIELDS,
)
from tests.api.tools_test_api import verify_fields
from tests.api.tools_test_api import ETUD_FIELDS, FSEM_FIELDS
ETUDID = 1
NIP = "1"
INE = "1"
def test_etudiants_courant(api_headers):
"""
Route: /etudiants/courant
"""
fields = {"id", "nip", "ine", "nom", "nom_usuel", "prenom", "civilite"}
fields = {"id", "nip", "nom", "prenom", "civilite"}
r = requests.get(
API_URL + "/etudiants/courant",
API_URL + "/etudiants/courants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -46,10 +76,18 @@ def test_etudiants_courant(api_headers):
etud = etudiants[-1]
assert verify_fields(etud, fields) is True
assert isinstance(etud["id"], int)
assert isinstance(etud["nip"], str)
assert isinstance(etud["nom"], str)
assert isinstance(etud["prenom"], str)
assert isinstance(etud["civilite"], str)
all_unique = verify_occurences_ids_etus(r.text)
assert all_unique is True
########## Version long ################
r = requests.get(
API_URL + "/etudiants/courant/long",
API_URL + "/etudiants/courants/long",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -63,77 +101,119 @@ def test_etudiants_courant(api_headers):
def test_etudiant(api_headers):
"""
Routes: /etudiant/etudid, /etudiant/nip, /etudiant/ine
Routes : /etudiant/etudid/<int:etudid>, /etudiant/nip/<string:nip>, /etudiant/ine/<string:ine>
"""
######### Test etudid #########
r = requests.get(
API_URL + "/etudiant/etudid/1",
API_URL + "/etudiant/etudid/" + str(ETUDID),
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud = r.json()
assert verify_fields(etud, ETUD_FIELDS) is True
code_nip = r.json()["code_nip"]
code_ine = r.json()["code_ine"]
######### Test code nip #########
r = requests.get(
API_URL + "/etudiant/nip/1",
API_URL + "/etudiant/nip/" + code_nip,
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud = r.json()
etud_nip = r.json()
fields_ok = verify_fields(etud, ETUD_FIELDS)
assert fields_ok is True
assert etud["dept_acronym"] == DEPT_ACRONYM
######### Test code ine #########
r = requests.get(
API_URL + "/etudiant/ine/INE1",
API_URL + "/etudiant/ine/" + code_ine,
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud_ine = r.json()
assert len(etud) == 26
fields_ok = verify_fields(etud, ETUD_FIELDS)
assert fields_ok is True
assert etud == etud_nip == etud_ine
def test_etudiants(api_headers):
"""
Route : /etudiants/etudid/<int:etudid>, /etudiants/nip/<string:nip>, /etudiants/ine/<string:ine>
"""
######### Test etudid #########
r = requests.get(
API_URL + "/etudiants/etudid/" + str(ETUDID),
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud = r.json()
assert len(etud) == 25
fields_ok = verify_fields(etud, ETUD_FIELDS)
code_nip = etud[0]["code_nip"]
code_ine = etud[0]["code_ine"]
assert isinstance(etud, list)
assert len(etud) == 1
fields_ok = verify_fields(etud[0], ETUD_FIELDS)
assert fields_ok is True
# Vérifie le requetage des 3 1er étudiants
for etudid in (1, 2, 3):
r = requests.get(
f"{API_URL }/etudiant/etudid/{etudid}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud = r.json()
nip = etud["code_nip"]
ine = etud["code_ine"]
assert isinstance(etud["id"], int)
assert isinstance(nip, str)
assert isinstance(ine, str)
r = requests.get(
f"{API_URL }/etudiant/nip/{nip}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud_nip = r.json()
# On doit avoir obtenue le même étudiant
assert etud_nip == etud
r = requests.get(
f"{API_URL }/etudiant/ine/{ine}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud_ine = r.json()
# On doit avoir obtenue le même étudiant
assert etud_ine == etud
######### Test code nip #########
r = requests.get(
API_URL + "/etudiants/nip/" + code_nip,
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud_nip = r.json()
assert isinstance(etud_nip, list)
fields_ok = verify_fields(etud_nip[0], ETUD_FIELDS)
assert fields_ok is True
all_unique = True
list_ids = [etud["id"] for etud in etud_nip]
for id in list_ids:
if list_ids.count(id) > 1:
all_unique = False
assert all_unique is True
######### Test code ine #########
r = requests.get(
API_URL + "/etudiants/ine/" + code_ine,
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
etud_ine = r.json()
assert isinstance(etud_ine, list)
fields_ok = verify_fields(etud_ine[0], ETUD_FIELDS)
assert fields_ok is True
all_unique = True
list_ids = [etud["id"] for etud in etud_ine]
for id in list_ids:
if list_ids.count(id) > 1:
all_unique = False
assert all_unique is True
####### Erreurs #######
r = requests.get(
API_URL + "/etudiants/etudid/",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
def test_etudiant_formsemestres(api_headers):
@ -144,20 +224,52 @@ def test_etudiant_formsemestres(api_headers):
######### Test etudid #########
r = requests.get(
API_URL + "/etudiant/etudid/1/formsemestres",
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestres",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
formsemestres = r.json()
assert len(formsemestres) == 1
list_formsemestres = r.json()
assert len(list_formsemestres) == 1
formsemestre = list_formsemestres[0]
assert isinstance(formsemestre["id"], int)
assert isinstance(formsemestre["bul_bgcolor"], str)
assert isinstance(formsemestre["date_debut"], str)
assert isinstance(formsemestre["date_fin"], str)
assert isinstance(formsemestre["resp_can_edit"], bool)
assert isinstance(formsemestre["dept_id"], int)
assert isinstance(formsemestre["etat"], bool)
assert isinstance(formsemestre["resp_can_change_ens"], bool)
assert isinstance(formsemestre["modalite"], str)
assert isinstance(formsemestre["ens_can_edit_eval"], bool)
assert isinstance(formsemestre["formation_id"], int)
assert isinstance(formsemestre["gestion_compensation"], bool)
assert formsemestre["elt_sem_apo"] is None or isinstance(
formsemestre["elt_sem_apo"], str
)
assert isinstance(formsemestre["semestre_id"], int)
assert isinstance(formsemestre["bul_hide_xml"], bool)
assert formsemestre["elt_annee_apo"] is None or isinstance(
formsemestre["elt_annee_apo"], str
)
assert isinstance(formsemestre["titre"], str)
assert isinstance(formsemestre["block_moyennes"], bool)
assert formsemestre["scodoc7_id"] is None or isinstance(
formsemestre["scodoc7_id"], int
)
assert isinstance(formsemestre["gestion_semestrielle"], bool)
assert isinstance(formsemestre["formsemestre_id"], int)
assert isinstance(formsemestre["titre_num"], str)
assert isinstance(formsemestre["date_debut_iso"], str)
assert isinstance(formsemestre["date_fin_iso"], str)
assert isinstance(formsemestre["responsables"], list)
assert isinstance(formsemestre["titre_formation"], str)
formsemestre = formsemestres[0]
assert verify_fields(formsemestre, FSEM_FIELDS) is True
######### Test code nip #########
r = requests.get(
API_URL + "/etudiant/nip/1/formsemestres",
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestres",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -170,7 +282,7 @@ def test_etudiant_formsemestres(api_headers):
######### Test code ine #########
r = requests.get(
API_URL + "/etudiant/ine/INE1/formsemestres",
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestres",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -186,10 +298,391 @@ def test_etudiant_bulletin_semestre(api_headers):
"""
Route: /etudiant/etudid/<etudid>/formsemestre/<formsemestre_id>/bulletin
"""
##################### LONG ########################
######### Test etudid #########
r = requests.get(
API_URL + "/etudiant/etudid/1/formsemestre/1/bulletin",
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
bulletin = r.json()
assert len(bulletin) == 13 # HARDCODED
assert verify_fields(bulletin, BULLETIN_FIELDS) is True
assert isinstance(bulletin["version"], str)
assert isinstance(bulletin["type"], str)
assert isinstance(bulletin["date"], str)
assert isinstance(bulletin["publie"], bool)
assert isinstance(bulletin["etudiant"], dict)
assert isinstance(bulletin["formation"], dict)
assert isinstance(bulletin["formsemestre_id"], int)
assert isinstance(bulletin["etat_inscription"], str)
assert isinstance(bulletin["options"], dict)
assert isinstance(bulletin["ressources"], dict)
assert isinstance(bulletin["saes"], dict)
assert isinstance(bulletin["ues"], dict)
assert isinstance(bulletin["semestre"], dict)
bulletin_etud = bulletin["etudiant"]
assert verify_fields(bulletin_etud, BULLETIN_ETUDIANT_FIELDS) is True
assert isinstance(bulletin_etud["civilite"], str)
assert isinstance(bulletin_etud["code_ine"], str)
assert isinstance(bulletin_etud["code_nip"], str)
assert isinstance(bulletin_etud["date_naissance"], str)
assert isinstance(bulletin_etud["dept_id"], int)
assert isinstance(bulletin_etud["dept_acronym"], str)
assert isinstance(bulletin_etud["email"], str)
assert isinstance(bulletin_etud["emailperso"], str)
assert isinstance(bulletin_etud["etudid"], int)
assert isinstance(bulletin_etud["nom"], str)
assert isinstance(bulletin_etud["prenom"], str)
assert isinstance(bulletin_etud["nomprenom"], str)
assert isinstance(bulletin_etud["lieu_naissance"], str)
assert isinstance(bulletin_etud["dept_naissance"], str)
assert isinstance(bulletin_etud["nationalite"], str)
assert isinstance(bulletin_etud["fiche_url"], str)
assert isinstance(bulletin_etud["photo_url"], str)
assert isinstance(bulletin_etud["id"], int)
assert isinstance(bulletin_etud["domicile"], str)
assert isinstance(bulletin_etud["villedomicile"], str)
assert isinstance(bulletin_etud["telephone"], str)
assert isinstance(bulletin_etud["fax"], str)
assert isinstance(bulletin_etud["description"], str)
assert isinstance(bulletin_etud["codepostaldomicile"], str)
assert isinstance(bulletin_etud["paysdomicile"], str)
assert isinstance(bulletin_etud["telephonemobile"], str)
assert isinstance(bulletin_etud["typeadresse"], str)
bulletin_formation = bulletin["formation"]
assert verify_fields(bulletin_formation, BULLETIN_FORMATION_FIELDS) is True
assert isinstance(bulletin_formation["id"], int)
assert isinstance(bulletin_formation["acronyme"], str)
assert isinstance(bulletin_formation["titre_officiel"], str)
assert isinstance(bulletin_formation["titre"], str)
bulletin_options = bulletin["options"]
assert verify_fields(bulletin_options, BULLETIN_OPTIONS_FIELDS) is True
assert isinstance(bulletin_options["show_abs"], bool)
assert isinstance(bulletin_options["show_abs_modules"], bool)
assert isinstance(bulletin_options["show_ects"], bool)
assert isinstance(bulletin_options["show_codemodules"], bool)
assert isinstance(bulletin_options["show_matieres"], bool)
assert isinstance(bulletin_options["show_rangs"], bool)
assert isinstance(bulletin_options["show_ue_rangs"], bool)
assert isinstance(bulletin_options["show_mod_rangs"], bool)
assert isinstance(bulletin_options["show_moypromo"], bool)
assert isinstance(bulletin_options["show_minmax"], bool)
assert isinstance(bulletin_options["show_minmax_mod"], bool)
assert isinstance(bulletin_options["show_minmax_eval"], bool)
assert isinstance(bulletin_options["show_coef"], bool)
assert isinstance(bulletin_options["show_ue_cap_details"], bool)
assert isinstance(bulletin_options["show_ue_cap_current"], bool)
assert isinstance(bulletin_options["show_temporary"], bool)
assert isinstance(bulletin_options["temporary_txt"], str)
assert isinstance(bulletin_options["show_uevalid"], bool)
assert isinstance(bulletin_options["show_date_inscr"], bool)
bulletin_ressources = bulletin["ressources"]
assert verify_fields(bulletin_ressources, BULLETIN_RESSOURCES_FIELDS) is True
assert isinstance(bulletin_ressources, dict)
for ressource in bulletin_ressources.values():
assert (
verify_fields(
ressource, BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS
)
is True
)
assert isinstance(ressource, dict)
assert isinstance(ressource["evaluations"], list)
for evaluation in ressource["evaluations"]:
assert (
verify_fields(
evaluation,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS,
)
is True
)
assert isinstance(evaluation["id"], int)
assert evaluation["description"] is None or isinstance(
evaluation["description"], str
)
assert evaluation["date"] is None or isinstance(evaluation["date"], str)
assert isinstance(evaluation["heure_debut"], str)
assert isinstance(evaluation["heure_fin"], str)
assert isinstance(evaluation["coef"], str)
assert isinstance(evaluation["poids"], dict)
assert isinstance(evaluation["note"], dict)
assert isinstance(evaluation["url"], str)
assert (
verify_fields(
evaluation["poids"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS,
)
is True
)
assert isinstance(evaluation["poids"]["RT1.1"], float)
assert isinstance(evaluation["poids"]["RT2.1"], float)
assert isinstance(evaluation["poids"]["RT3.1"], float)
assert (
verify_fields(
evaluation["note"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS,
)
is True
)
assert isinstance(evaluation["note"]["value"], str)
assert isinstance(evaluation["note"]["min"], str)
assert isinstance(evaluation["note"]["max"], str)
assert isinstance(evaluation["note"]["moy"], str)
bulletin_saes = bulletin["saes"]
assert verify_fields(bulletin_saes, BULLETIN_SAES_FIELDS) is True
assert isinstance(bulletin_saes, dict)
for sae in bulletin_saes.values():
assert (
verify_fields(sae, BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS)
is True
)
assert isinstance(sae, dict)
assert isinstance(sae["evaluations"], list)
for evaluation in sae["evaluations"]:
assert (
verify_fields(
evaluation,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS,
)
is True
)
assert isinstance(evaluation["id"], int)
assert evaluation["description"] is None or isinstance(
evaluation["description"], str
)
assert evaluation["date"] is None or isinstance(evaluation["date"], str)
assert isinstance(evaluation["heure_debut"], str)
assert isinstance(evaluation["heure_fin"], str)
assert isinstance(evaluation["coef"], str)
assert isinstance(evaluation["poids"], dict)
assert isinstance(evaluation["note"], dict)
assert isinstance(evaluation["url"], str)
assert (
verify_fields(
evaluation["poids"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS,
)
is True
)
assert isinstance(evaluation["poids"]["RT1.1"], float)
assert isinstance(evaluation["poids"]["RT2.1"], float)
assert isinstance(evaluation["poids"]["RT3.1"], float)
assert (
verify_fields(
evaluation["note"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS,
)
is True
)
assert isinstance(evaluation["note"]["value"], str)
assert isinstance(evaluation["note"]["min"], str)
assert isinstance(evaluation["note"]["max"], str)
assert isinstance(evaluation["note"]["moy"], str)
bulletin_ues = bulletin["ues"]
assert verify_fields(bulletin_ues, BULLETIN_UES_FIELDS) is True
assert isinstance(bulletin_ues, dict)
for (key_ue, value_ue) in bulletin_ues.items():
assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True
assert isinstance(value_ue["id"], int)
assert isinstance(value_ue["titre"], str)
assert isinstance(value_ue["numero"], int)
assert isinstance(value_ue["type"], int)
assert isinstance(value_ue["color"], str)
assert value_ue["competence"] is None or isinstance(value_ue["competence"], str)
assert isinstance(value_ue["moyenne"], dict)
assert isinstance(value_ue["bonus"], str)
assert isinstance(value_ue["malus"], str)
assert value_ue["capitalise"] is None or isinstance(value_ue["capitalise"], str)
assert isinstance(value_ue["ressources"], dict)
assert isinstance(value_ue["saes"], dict)
assert isinstance(value_ue["ECTS"], dict)
assert (
verify_fields(value_ue["moyenne"], BULLETIN_UES_UE_MOYENNE_FIELDS) is True
)
assert isinstance(value_ue["moyenne"]["value"], str)
assert isinstance(value_ue["moyenne"]["min"], str)
assert isinstance(value_ue["moyenne"]["max"], str)
assert isinstance(value_ue["moyenne"]["moy"], str)
assert isinstance(value_ue["moyenne"]["rang"], str)
assert isinstance(value_ue["moyenne"]["total"], int)
if key_ue == "RT1.1":
assert (
verify_fields(
bulletin_ues[key_ue]["ressources"],
BULLETIN_UES_RT11_RESSOURCES_FIELDS,
)
is True
)
assert (
verify_fields(
bulletin_ues[key_ue]["saes"], BULLETIN_UES_RT11_SAES_FIELDS
)
is True
)
elif key_ue == "RT2.1":
assert (
verify_fields(
bulletin_ues[key_ue]["ressources"],
BULLETIN_UES_RT21_RESSOURCES_FIELDS,
)
is True
)
assert (
verify_fields(
bulletin_ues[key_ue]["saes"], BULLETIN_UES_RT21_SAES_FIELDS
)
is True
)
elif key_ue == "RT3.1":
assert (
verify_fields(
bulletin_ues[key_ue]["ressources"],
BULLETIN_UES_RT31_RESSOURCES_FIELDS,
)
is True
)
assert (
verify_fields(
bulletin_ues[key_ue]["saes"], BULLETIN_UES_RT31_SAES_FIELDS
)
is True
)
for ressource in value_ue["ressources"].values():
assert (
verify_fields(ressource, BULLETIN_UES_UE_RESSOURCES_RESSOURCE_FIELDS)
is True
)
assert isinstance(ressource["id"], int)
assert isinstance(ressource["coef"], float)
assert isinstance(ressource["moyenne"], str)
for sae in value_ue["saes"].values():
assert verify_fields(sae, BULLETIN_UES_UE_SAES_SAE_FIELDS) is True
assert isinstance(sae["id"], int)
assert isinstance(sae["coef"], float)
assert isinstance(sae["moyenne"], str)
assert verify_fields(value_ue["ECTS"], BULLETIN_UES_UE_ECTS_FIELDS) is True
assert isinstance(value_ue["ECTS"]["acquis"], float)
assert isinstance(value_ue["ECTS"]["total"], float)
bulletin_semestre = bulletin["semestre"]
assert verify_fields(bulletin_semestre, BULLETIN_SEMESTRE_FIELDS) is True
assert isinstance(bulletin_semestre["etapes"], list)
assert isinstance(bulletin_semestre["date_debut"], str)
assert isinstance(bulletin_semestre["date_fin"], str)
assert isinstance(bulletin_semestre["annee_universitaire"], str)
assert isinstance(bulletin_semestre["numero"], int)
assert isinstance(bulletin_semestre["inscription"], str)
assert isinstance(bulletin_semestre["groupes"], list)
assert isinstance(bulletin_semestre["absences"], dict)
assert isinstance(bulletin_semestre["ECTS"], dict)
assert isinstance(bulletin_semestre["notes"], dict)
assert isinstance(bulletin_semestre["rang"], dict)
assert (
verify_fields(bulletin_semestre["absences"], BULLETIN_SEMESTRE_ABSENCES_FIELDS)
is True
)
assert isinstance(bulletin_semestre["absences"]["injustifie"], int)
assert isinstance(bulletin_semestre["absences"]["total"], int)
assert (
verify_fields(bulletin_semestre["ECTS"], BULLETIN_SEMESTRE_ECTS_FIELDS) is True
)
assert isinstance(bulletin_semestre["ECTS"]["acquis"], int)
assert isinstance(bulletin_semestre["ECTS"]["total"], float)
assert (
verify_fields(bulletin_semestre["notes"], BULLETIN_SEMESTRE_NOTES_FIELDS)
is True
)
assert isinstance(bulletin_semestre["notes"]["value"], str)
assert isinstance(bulletin_semestre["notes"]["min"], str)
assert isinstance(bulletin_semestre["notes"]["max"], str)
assert isinstance(bulletin_semestre["notes"]["moy"], str)
assert (
verify_fields(bulletin_semestre["rang"], BULLETIN_SEMESTRE_RANG_FIELDS) is True
)
assert isinstance(bulletin_semestre["rang"]["value"], str)
assert isinstance(bulletin_semestre["rang"]["total"], int)
######### Test code nip #########
r = requests.get(
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
bul = r.json()
assert len(bul) == 13 # HARDCODED
######### Test code ine #########
r = requests.get(
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
bul = r.json()
assert len(bul) == 13 # HARDCODED
################### LONG + PDF #####################
# ######### Test etudid #########
#
# r = requests.get(
# API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# ######### Test code nip #########
#
# r = requests.get(
# API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# ######### Test code ine #########
# r = requests.get(
# API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
################### SHORT #####################
######### Test etudid #########
r = requests.get(
API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -200,7 +693,7 @@ def test_etudiant_bulletin_semestre(api_headers):
######### Test code nip #########
r = requests.get(
API_URL + "/etudiant/nip/1/formsemestre/1/bulletin",
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -210,7 +703,7 @@ def test_etudiant_bulletin_semestre(api_headers):
######### Test code ine #########
r = requests.get(
API_URL + "/etudiant/ine/INE1/formsemestre/1/bulletin",
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -218,6 +711,33 @@ def test_etudiant_bulletin_semestre(api_headers):
bul = r.json()
assert len(bul) == 13 # HARDCODED
################### SHORT + PDF #####################
# ######### Test etudid #########
# r = requests.get(
# API_URL + "/etudiant/etudid/" + str(ETUDID) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# ######### Test code nip #########
#
# r = requests.get(
# API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
#
# ######### Test code ine #########
# r = requests.get(
# API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/bulletin/short/pdf",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
### --- Test étudiant inexistant
r = requests.get(
API_URL + "/etudiant/ine/189919919119191/formsemestre/1/bulletin",
@ -260,7 +780,7 @@ def test_etudiant_groups(api_headers):
######### Test code nip #########
r = requests.get(
API_URL + "/etudiant/nip/1/formsemestre/1/groups",
API_URL + "/etudiant/nip/" + str(NIP) + "/formsemestre/1/groups",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
@ -273,7 +793,7 @@ def test_etudiant_groups(api_headers):
######### Test code ine #########
r = requests.get(
API_URL + "/etudiant/ine/INE1/formsemestre/1/groups",
API_URL + "/etudiant/ine/" + str(INE) + "/formsemestre/1/groups",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)

View File

@ -20,30 +20,79 @@ Utilisation :
import requests
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import (
verify_fields,
EVALUATIONS_FIELDS,
EVALUATION_FIELDS,
)
def test_evaluations(api_headers):
"""
Route: /evaluation/<int:moduleimpl_id>
Test 'evaluations'
Route :
- /evaluations/<int:moduleimpl_id>
"""
moduleimpl_id = 1
r = requests.get(
API_URL + "/evaluations/1",
f"{API_URL}/evaluations/{moduleimpl_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# TODO
list_eval = r.json()
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["jour"], str)
assert isinstance(eval["heure_fin"], str)
assert isinstance(eval["note_max"], float)
assert isinstance(eval["visibulletin"], bool)
assert isinstance(eval["evaluation_type"], int)
assert isinstance(eval["moduleimpl_id"], int)
assert isinstance(eval["heure_debut"], str)
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 isinstance(eval["evaluation_id"], 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["jouriso"] is None or isinstance(eval["jouriso"], str)
assert isinstance(eval["duree"], str)
assert isinstance(eval["descrheure"], str)
assert isinstance(eval["matin"], int)
assert isinstance(eval["apresmidi"], int)
assert eval["moduleimpl_id"] == moduleimpl_id
# TODO car pas d'évaluations créées à ce stade
# def test_evaluation_notes(api_headers):
# """
# Route: /evaluation/eval_notes/<int:evaluation_id>
# """
# r = requests.get(
# API_URL + "/evaluation/eval_notes/1",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# # TODO
def test_evaluation_notes(api_headers): # XXX TODO changer la boucle pour parcourir le dict sans les indices
"""
Test 'evaluation_notes'
Route :
- /evaluation/eval_notes/<int:evaluation_id>
"""
eval_id = 1
r = requests.get(
f"{API_URL}/evaluation/eval_notes/{eval_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
eval_notes = r.json()
for i in range(1, len(eval_notes)):
assert verify_fields(eval_notes[f"{i}"], EVALUATION_FIELDS)
assert isinstance(eval_notes[f"{i}"]["id"], int)
assert isinstance(eval_notes[f"{i}"]["etudid"], int)
assert isinstance(eval_notes[f"{i}"]["evaluation_id"], int)
assert isinstance(eval_notes[f"{i}"]["value"], float)
assert isinstance(eval_notes[f"{i}"]["comment"], str)
assert isinstance(eval_notes[f"{i}"]["date"], str)
assert isinstance(eval_notes[f"{i}"]["uid"], int)
assert eval_id == eval_notes[f"{i}"]["evaluation_id"]

View File

@ -20,7 +20,16 @@ Utilisation :
import requests
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import verify_fields
from tests.api.tools_test_api import (
verify_fields,
FORMATION_EXPORT_FIELDS,
FORMATION_EXPORT_UE_FIELDS,
FORMATION_EXPORT_UE_MATIERE_FIELDS,
FORMATION_EXPORT_UE_MATIERE_MODULE_FIELDS,
FORMATION_EXPORT_UE_MATIERE_MODULE_COEF_FIELDS,
MODULE_FIELDS,
REF_COMP_FIELDS,
)
from tests.api.tools_test_api import FORMATION_FIELDS, MODIMPL_FIELDS
@ -45,15 +54,52 @@ def test_formations_by_id(api_headers):
"""
Route: /formation/<int:formation_id>
"""
id_formation = 1
r = requests.get(
API_URL + "/formation/1",
f"{API_URL}/formation/{id_formation}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
formation = r.json()
assert verify_fields(formation, FORMATION_FIELDS) is True
# TODO tester le contenu de certains champs
assert isinstance(formation["dept_id"], int)
assert isinstance(formation["acronyme"], str)
assert isinstance(formation["titre_officiel"], str)
assert isinstance(formation["formation_code"], str)
assert formation["code_specialite"] is None or isinstance(
formation["code_specialite"], str
)
assert isinstance(formation["id"], int)
assert isinstance(formation["titre"], str)
assert isinstance(formation["version"], int)
assert isinstance(formation["type_parcours"], int)
assert formation["referentiel_competence_id"] is None or isinstance(
formation["referentiel_competence_id"], int
)
assert isinstance(formation["formation_id"], int)
assert id_formation == formation["formation_id"]
assert id_formation == formation["id"]
r1 = requests.get(
f"{API_URL}/formation/{formation['formation_id']}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r1.status_code == 200
formation1 = r1.json()
assert formation == formation1
# ERROR
id_formation_inexistant = 1516476846861656351
r_error = requests.get(
f"{API_URL}/formation/{id_formation_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404
def test_formation_export(api_headers):
@ -67,33 +113,150 @@ def test_formation_export(api_headers):
)
assert r.status_code == 200
export_formation = r.json()
assert verify_fields(export_formation, FORMATION_FIELDS) is True
# TODO tester le contenu de certains champs
assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True
assert isinstance(export_formation["dept_id"], int)
assert isinstance(export_formation["acronyme"], str)
assert isinstance(export_formation["titre_officiel"], str)
assert isinstance(export_formation["formation_code"], str)
assert export_formation["code_specialite"] is None or isinstance(
export_formation["code_specialite"], str
)
assert isinstance(export_formation["id"], int)
assert isinstance(export_formation["titre"], str)
assert isinstance(export_formation["version"], int)
assert isinstance(export_formation["type_parcours"], int)
assert export_formation["referentiel_competence_id"] is None or isinstance(
export_formation["referentiel_competence_id"], int
)
assert isinstance(export_formation["formation_id"], int)
assert isinstance(export_formation["ue"], list)
ues = export_formation["ue"]
# TODO
# def test_formsemestre_apo(api_headers):
# r = requests.get(
# API_URL + "/formation/apo/<string:etape_apo>",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
for ue in ues:
assert verify_fields(ue, FORMATION_EXPORT_UE_FIELDS) is True
assert isinstance(ue["acronyme"], str)
assert isinstance(ue["numero"], int)
assert isinstance(ue["titre"], str)
assert isinstance(ue["type"], int)
assert isinstance(ue["ue_code"], str)
assert isinstance(ue["ects"], float)
assert isinstance(ue["is_external"], bool)
assert isinstance(ue["code_apogee"], str)
assert isinstance(ue["coefficient"], float)
assert isinstance(ue["semestre_idx"], int)
assert isinstance(ue["color"], str)
assert isinstance(ue["reference"], int)
assert isinstance(ue["matiere"], list)
matieres = ue["matiere"]
for matiere in matieres:
assert verify_fields(matiere, FORMATION_EXPORT_UE_MATIERE_FIELDS)
assert isinstance(matiere["titre"], str)
assert isinstance(matiere["numero"], int)
assert isinstance(matiere["module"], list)
modules = matiere["module"]
for module in modules:
assert verify_fields(module, FORMATION_EXPORT_UE_MATIERE_MODULE_FIELDS)
assert isinstance(module["titre"], str)
assert isinstance(module["abbrev"], str)
assert isinstance(module["code"], str)
assert isinstance(module["heures_cours"], float)
assert isinstance(module["heures_td"], float)
assert isinstance(module["heures_tp"], float)
assert isinstance(module["coefficient"], float)
assert isinstance(module["ects"], str)
assert isinstance(module["semestre_id"], int)
assert isinstance(module["numero"], int)
assert isinstance(module["code_apogee"], str)
assert isinstance(module["module_type"], int)
assert isinstance(module["coefficients"], list)
coefficients = module["coefficients"]
for coef in coefficients:
assert verify_fields(
coef, FORMATION_EXPORT_UE_MATIERE_MODULE_COEF_FIELDS
)
assert isinstance(coef["ue_reference"], str)
assert isinstance(coef["coef"], str)
# ERROR
id_formation_inexistant = 1516476846861656351
r_error = requests.get(
f"{API_URL}/formation/formation_export/{id_formation_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404
def test_moduleimpl(api_headers):
"""
Route: /formation/moduleimpl/<int:moduleimpl_id>
"""
moduleimpl_id = 1
r = requests.get(
API_URL + "/formation/moduleimpl/1",
f"{API_URL}/formation/moduleimpl/{moduleimpl_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
moduleimpl = r.json()
assert verify_fields(moduleimpl, MODIMPL_FIELDS) is True
# TODO tester le contenu de certains champs
assert isinstance(moduleimpl["id"], int)
assert isinstance(moduleimpl["responsable_id"], int)
assert isinstance(moduleimpl["module_id"], int)
assert isinstance(moduleimpl["formsemestre_id"], int)
assert moduleimpl["computation_expr"] is None or isinstance(
moduleimpl["computation_expr"], str
)
assert isinstance(moduleimpl["moduleimpl_id"], int)
assert isinstance(moduleimpl["ens"], list)
assert isinstance(moduleimpl["module"], dict)
module = moduleimpl["module"]
assert verify_fields(module, MODULE_FIELDS)
assert isinstance(module["heures_cours"], float)
assert isinstance(module["semestre_id"], int)
assert isinstance(module["heures_td"], float)
assert isinstance(module["numero"], int)
assert isinstance(module["heures_tp"], float)
assert isinstance(module["code_apogee"], str)
assert isinstance(module["titre"], str)
assert isinstance(module["coefficient"], float)
assert isinstance(module["module_type"], int)
assert isinstance(module["id"], int)
assert module["ects"] is None or isinstance(module["ects"], str)
assert isinstance(module["abbrev"], str)
assert isinstance(module["ue_id"], int)
assert isinstance(module["code"], str)
assert isinstance(module["formation_id"], int)
assert isinstance(module["matiere_id"], int)
assert isinstance(module["module_id"], int)
assert moduleimpl_id == moduleimpl["id"]
assert moduleimpl_id == moduleimpl["moduleimpl_id"]
r1 = requests.get(
f"{API_URL}/formation/moduleimpl/{moduleimpl['moduleimpl_id']}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r1.status_code == 200
moduleimpl1 = r1.json()
assert moduleimpl == moduleimpl1
# ERROR
id_formation_inexistant = 1516476846861656351
r_error = requests.get(
f"{API_URL}/formation/moduleimpl/{id_formation_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404
def test_referentiel_competences(api_headers):
@ -101,9 +264,32 @@ def test_referentiel_competences(api_headers):
Route: "/formation/<int:formation_id>/referentiel_competences",
"""
r = requests.get(
API_URL + "/formation/1/referentiel_competences",
f"{API_URL}/formation/1/referentiel_competences",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# XXX A compléter
ref_comp = r.json()
assert verify_fields(ref_comp, REF_COMP_FIELDS) is True
assert isinstance(ref_comp["dept_id"], int)
assert isinstance(ref_comp["annexe"], str)
assert isinstance(ref_comp["specialite"], str)
assert isinstance(ref_comp["specialite_long"], str)
assert isinstance(ref_comp["type_structure"], str)
assert isinstance(ref_comp["type_departement"], str)
assert isinstance(ref_comp["type_titre"], str)
assert isinstance(ref_comp["version_orebut"], str)
assert isinstance(ref_comp["scodoc_date_loaded"], str)
assert isinstance(ref_comp["scodoc_orig_filename"], str)
assert isinstance(ref_comp["competences"], dict)
assert isinstance(ref_comp["parcours"], dict)
# ERROR
id_formation_inexistant = 1516476846861656351
r_error = requests.get(
f"{API_URL}/formation/{id_formation_inexistant}/referentiel_competences",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404

View File

@ -21,8 +21,36 @@ import requests
from app.api.formsemestres import formsemestre
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import MODIMPL_FIELDS, verify_fields
from tests.api.tools_test_api import FSEM_FIELDS, UE_FIELDS, MODULE_FIELDS
from tests.api.tools_test_api import (
verify_fields,
MODIMPL_FIELDS,
EVAL_FIELDS,
SAISIE_NOTES_FIELDS,
FORMSEMESTRE_ETUS_FIELDS,
FSEM_FIELDS,
FSEM_FIELDS,
UE_FIELDS,
MODULE_FIELDS,
FORMSEMESTRE_BULLETINS_FIELDS,
FORMSEMESTRE_BULLETINS_ETU_FIELDS,
FORMSEMESTRE_BULLETINS_FORMATION_FIELDS,
FORMSEMESTRE_BULLETINS_OPT_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS,
BULLETIN_UES_UE_FIELDS,
BULLETIN_UES_UE_MOYENNE_FIELDS,
BULLETIN_UES_UE_RESSOURCES_RESSOURCE_FIELDS,
BULLETIN_UES_UE_SAES_SAE_FIELDS,
BULLETIN_UES_UE_ECTS_FIELDS,
BULLETIN_SEMESTRE_FIELDS,
BULLETIN_SEMESTRE_ABSENCES_FIELDS,
BULLETIN_SEMESTRE_ECTS_FIELDS,
BULLETIN_SEMESTRE_NOTES_FIELDS,
BULLETIN_SEMESTRE_RANG_FIELDS,
)
# Etudiant pour les tests
ETUDID = 1
@ -34,62 +62,421 @@ def test_formsemestre(api_headers):
"""
Route: /formsemestre/<id>
"""
formsemestre_id = 1
r = requests.get(
API_URL + "/formsemestre/1",
f"{API_URL}/formsemestre/{formsemestre_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
formsemestre = r.json()
assert verify_fields(formsemestre, FSEM_FIELDS)
assert isinstance(formsemestre["block_moyennes"], bool)
assert isinstance(formsemestre["bul_bgcolor"], str)
assert isinstance(formsemestre["bul_hide_xml"], bool)
assert isinstance(formsemestre["date_debut_iso"], str)
assert isinstance(formsemestre["date_debut"], str)
assert isinstance(formsemestre["date_fin_iso"], str)
assert isinstance(formsemestre["date_fin"], str)
assert isinstance(formsemestre["dept_id"], int)
assert formsemestre["elt_annee_apo"] is None or isinstance(
formsemestre["elt_annee_apo"], str
)
assert formsemestre["elt_sem_apo"] is None or isinstance(
formsemestre["elt_sem_apo"], str
)
assert isinstance(formsemestre["ens_can_edit_eval"], bool)
assert isinstance(formsemestre["etat"], bool)
assert isinstance(formsemestre["formation_id"], int)
assert isinstance(formsemestre["formsemestre_id"], int)
assert isinstance(formsemestre["gestion_compensation"], bool)
assert isinstance(formsemestre["gestion_semestrielle"], bool)
assert isinstance(formsemestre["id"], int)
assert isinstance(formsemestre["modalite"], str)
assert isinstance(formsemestre["resp_can_change_ens"], bool)
assert isinstance(formsemestre["resp_can_edit"], bool)
assert isinstance(formsemestre["responsables"], list)
assert formsemestre["scodoc7_id"] is None or isinstance(
formsemestre["scodoc7_id"], int
)
assert isinstance(formsemestre["semestre_id"], int)
assert isinstance(formsemestre["titre_formation"], str)
assert isinstance(formsemestre["titre_num"], str)
assert isinstance(formsemestre["titre"], str)
### ERROR ###
formsemestre_id_inexistant = 165456165165136513510351
r = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
def test_etudiant_bulletin(api_headers):
def test_formsemestre_apo(api_headers):
"""
Route:
Route: /formsemestre/apo/<string:etape_apo>
"""
formsemestre_id = 1
etape_apo = "A1"
r = requests.get(
f"{API_URL}/etudiant/etudid/1/formsemestre/{formsemestre_id}/bulletin",
f"{API_URL}/formsemestre/apo/{etape_apo}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
bull_a = r.json()
list_formsemestre = r.json()
assert isinstance(list_formsemestre, list)
r = requests.get(
f"{API_URL}/etudiant/nip/{NIP}/formsemestre/{formsemestre_id}/bulletin",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
bull_b = r.json()
for formsemestre in list_formsemestre:
assert isinstance(formsemestre, dict)
assert verify_fields(formsemestre, FSEM_FIELDS)
assert isinstance(formsemestre["block_moyennes"], bool)
assert isinstance(formsemestre["bul_bgcolor"], str)
assert isinstance(formsemestre["bul_hide_xml"], bool)
assert isinstance(formsemestre["date_debut_iso"], str)
assert isinstance(formsemestre["date_debut"], str)
assert isinstance(formsemestre["date_fin_iso"], str)
assert isinstance(formsemestre["date_fin"], str)
assert isinstance(formsemestre["dept_id"], int)
assert formsemestre["elt_annee_apo"] is None or isinstance(
formsemestre["elt_annee_apo"], str
)
assert formsemestre["elt_sem_apo"] is None or isinstance(
formsemestre["elt_sem_apo"], str
)
assert isinstance(formsemestre["ens_can_edit_eval"], bool)
assert isinstance(formsemestre["etat"], bool)
assert isinstance(formsemestre["formation_id"], int)
assert isinstance(formsemestre["formsemestre_id"], int)
assert isinstance(formsemestre["gestion_compensation"], bool)
assert isinstance(formsemestre["gestion_semestrielle"], bool)
assert isinstance(formsemestre["id"], int)
assert isinstance(formsemestre["modalite"], str)
assert isinstance(formsemestre["resp_can_change_ens"], bool)
assert isinstance(formsemestre["resp_can_edit"], bool)
assert isinstance(formsemestre["responsables"], list)
assert formsemestre["scodoc7_id"] is None or isinstance(
formsemestre["scodoc7_id"], int
)
assert isinstance(formsemestre["semestre_id"], int)
assert isinstance(formsemestre["titre_formation"], str)
assert isinstance(formsemestre["titre_num"], str)
assert isinstance(formsemestre["titre"], str)
r = requests.get(
f"{API_URL}/etudiant/ine/{INE}/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
### ERROR ###
# etape_apo_inexistante = "aoefiaozidaoẑidjnoaiznjd"
# r_error = requests.get(
# f"{API_URL}/formsemestre/apo/{etape_apo_inexistante}",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r_error.status_code == 404
def test_bulletins(api_headers):
"""
Route:
Route: /formsemestre/<int:formsemestre_id>/bulletins
"""
formsemestre_id = 1
r = requests.get(
API_URL + "/formsemestre/1/bulletins",
f"{API_URL}/formsemestre/{formsemestre_id}/bulletins",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
bulletins = r.json()
assert isinstance(bulletins, list)
for bul in bulletins:
assert verify_fields(bul, FORMSEMESTRE_BULLETINS_FIELDS) is True
assert isinstance(bul["version"], str)
assert isinstance(bul["type"], str)
assert isinstance(bul["date"], str)
assert isinstance(bul["publie"], bool)
assert isinstance(bul["etudiant"], dict)
assert isinstance(bul["formation"], dict)
assert isinstance(bul["formsemestre_id"], int)
assert isinstance(bul["etat_inscription"], str)
assert isinstance(bul["options"], dict)
assert isinstance(bul["ressources"], dict)
assert isinstance(bul["saes"], dict)
assert isinstance(bul["ues"], dict)
assert isinstance(bul["semestre"], dict)
formsemestre_id_bul = bul["formsemestre_id"]
assert formsemestre_id == formsemestre_id_bul
etudiant = bul["etudiant"]
assert verify_fields(etudiant, FORMSEMESTRE_BULLETINS_ETU_FIELDS) is True
assert isinstance(etudiant["civilite"], str)
assert isinstance(etudiant["code_ine"], str)
assert isinstance(etudiant["code_nip"], str)
assert isinstance(etudiant["date_naissance"], str)
assert isinstance(etudiant["dept_id"], int)
assert isinstance(etudiant["dept_acronym"], str)
assert isinstance(etudiant["email"], str)
assert isinstance(etudiant["emailperso"], str)
assert isinstance(etudiant["etudid"], int)
assert isinstance(etudiant["nom"], str)
assert isinstance(etudiant["prenom"], str)
assert isinstance(etudiant["nomprenom"], str)
assert isinstance(etudiant["lieu_naissance"], str)
assert isinstance(etudiant["dept_naissance"], str)
assert isinstance(etudiant["nationalite"], str)
assert isinstance(etudiant["boursier"], str)
assert isinstance(etudiant["fiche_url"], str)
assert isinstance(etudiant["photo_url"], str)
assert isinstance(etudiant["id"], int)
assert isinstance(etudiant["codepostaldomicile"], str)
assert isinstance(etudiant["paysdomicile"], str)
assert isinstance(etudiant["telephonemobile"], str)
assert isinstance(etudiant["typeadresse"], str)
assert isinstance(etudiant["domicile"], str)
assert isinstance(etudiant["villedomicile"], str)
assert isinstance(etudiant["telephone"], str)
assert isinstance(etudiant["fax"], str)
assert isinstance(etudiant["description"], str)
formation = bul["formation"]
assert verify_fields(formation, FORMSEMESTRE_BULLETINS_FORMATION_FIELDS) is True
assert isinstance(formation["id"], int)
assert isinstance(formation["acronyme"], str)
assert isinstance(formation["titre_officiel"], str)
assert isinstance(formation["titre"], str)
options = bul["options"]
assert verify_fields(options, FORMSEMESTRE_BULLETINS_OPT_FIELDS) is True
assert isinstance(options["show_abs"], bool)
assert isinstance(options["show_abs_modules"], bool)
assert isinstance(options["show_ects"], bool)
assert isinstance(options["show_codemodules"], bool)
assert isinstance(options["show_matieres"], bool)
assert isinstance(options["show_rangs"], bool)
assert isinstance(options["show_ue_rangs"], bool)
assert isinstance(options["show_mod_rangs"], bool)
assert isinstance(options["show_moypromo"], bool)
assert isinstance(options["show_minmax"], bool)
assert isinstance(options["show_minmax_mod"], bool)
assert isinstance(options["show_minmax_eval"], bool)
assert isinstance(options["show_coef"], bool)
assert isinstance(options["show_ue_cap_details"], bool)
assert isinstance(options["show_ue_cap_current"], bool)
assert isinstance(options["show_temporary"], bool)
assert isinstance(options["temporary_txt"], str)
assert isinstance(options["show_uevalid"], bool)
assert isinstance(options["show_date_inscr"], bool)
bulletin_ressources = bul["ressources"]
assert isinstance(bulletin_ressources, dict)
for ressource in bulletin_ressources.values():
assert (
verify_fields(
ressource, BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS
)
is True
)
assert isinstance(ressource, dict)
assert isinstance(ressource["evaluations"], list)
for evaluation in ressource["evaluations"]:
assert (
verify_fields(
evaluation,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS,
)
is True
)
assert isinstance(evaluation["id"], int)
assert evaluation["description"] is None or isinstance(
evaluation["description"], str
)
assert evaluation["date"] is None or isinstance(evaluation["date"], str)
assert isinstance(evaluation["heure_debut"], str)
assert isinstance(evaluation["heure_fin"], str)
assert isinstance(evaluation["coef"], str)
assert isinstance(evaluation["poids"], dict)
assert isinstance(evaluation["note"], dict)
assert isinstance(evaluation["url"], str)
assert (
verify_fields(
evaluation["poids"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS,
)
is True
)
assert isinstance(evaluation["poids"]["RT1.1"], float)
assert isinstance(evaluation["poids"]["RT2.1"], float)
assert isinstance(evaluation["poids"]["RT3.1"], float)
assert (
verify_fields(
evaluation["note"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS,
)
is True
)
assert isinstance(evaluation["note"]["value"], str)
assert isinstance(evaluation["note"]["min"], str)
assert isinstance(evaluation["note"]["max"], str)
assert isinstance(evaluation["note"]["moy"], str)
bulletin_saes = bul["saes"]
assert isinstance(bulletin_saes, dict)
for sae in bulletin_saes.values():
assert (
verify_fields(sae, BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS)
is True
)
assert isinstance(sae, dict)
assert isinstance(sae["evaluations"], list)
for evaluation in sae["evaluations"]:
assert (
verify_fields(
evaluation,
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS,
)
is True
)
assert isinstance(evaluation["id"], int)
assert evaluation["description"] is None or isinstance(
evaluation["description"], str
)
assert evaluation["date"] is None or isinstance(evaluation["date"], str)
assert isinstance(evaluation["heure_debut"], str)
assert isinstance(evaluation["heure_fin"], str)
assert isinstance(evaluation["coef"], str)
assert isinstance(evaluation["poids"], dict)
assert isinstance(evaluation["note"], dict)
assert isinstance(evaluation["url"], str)
assert (
verify_fields(
evaluation["poids"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS,
)
is True
)
assert isinstance(evaluation["poids"]["RT1.1"], float)
assert isinstance(evaluation["poids"]["RT2.1"], float)
assert isinstance(evaluation["poids"]["RT3.1"], float)
assert (
verify_fields(
evaluation["note"],
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS,
)
is True
)
assert isinstance(evaluation["note"]["value"], str)
assert isinstance(evaluation["note"]["min"], str)
assert isinstance(evaluation["note"]["max"], str)
assert isinstance(evaluation["note"]["moy"], str)
bulletin_ues = bul["ues"]
assert isinstance(bulletin_ues, dict)
for (key_ue, value_ue) in bulletin_ues.items():
assert verify_fields(value_ue, BULLETIN_UES_UE_FIELDS) is True
assert isinstance(value_ue["id"], int)
assert isinstance(value_ue["titre"], str)
assert isinstance(value_ue["numero"], int)
assert isinstance(value_ue["type"], int)
assert isinstance(value_ue["color"], str)
assert value_ue["competence"] is None or isinstance(
value_ue["competence"], str
)
assert isinstance(value_ue["moyenne"], dict)
assert isinstance(value_ue["bonus"], str)
assert isinstance(value_ue["malus"], str)
assert value_ue["capitalise"] is None or isinstance(
value_ue["capitalise"], str
)
assert isinstance(value_ue["ressources"], dict)
assert isinstance(value_ue["saes"], dict)
assert isinstance(value_ue["ECTS"], dict)
assert (
verify_fields(value_ue["moyenne"], BULLETIN_UES_UE_MOYENNE_FIELDS)
is True
)
assert isinstance(value_ue["moyenne"]["value"], str)
assert isinstance(value_ue["moyenne"]["min"], str)
assert isinstance(value_ue["moyenne"]["max"], str)
assert isinstance(value_ue["moyenne"]["moy"], str)
assert isinstance(value_ue["moyenne"]["rang"], str)
assert isinstance(value_ue["moyenne"]["total"], int)
for ressource in value_ue["ressources"].values():
assert (
verify_fields(
ressource, BULLETIN_UES_UE_RESSOURCES_RESSOURCE_FIELDS
)
is True
)
assert isinstance(ressource["id"], int)
assert isinstance(ressource["coef"], float)
assert isinstance(ressource["moyenne"], str)
for sae in value_ue["saes"].values():
assert verify_fields(sae, BULLETIN_UES_UE_SAES_SAE_FIELDS) is True
assert isinstance(sae["id"], int)
assert isinstance(sae["coef"], float)
assert isinstance(sae["moyenne"], str)
assert verify_fields(value_ue["ECTS"], BULLETIN_UES_UE_ECTS_FIELDS) is True
assert isinstance(value_ue["ECTS"]["acquis"], float)
assert isinstance(value_ue["ECTS"]["total"], float)
bulletin_semestre = bul["semestre"]
assert verify_fields(bulletin_semestre, BULLETIN_SEMESTRE_FIELDS) is True
assert isinstance(bulletin_semestre["etapes"], list)
assert isinstance(bulletin_semestre["date_debut"], str)
assert isinstance(bulletin_semestre["date_fin"], str)
assert isinstance(bulletin_semestre["annee_universitaire"], str)
assert isinstance(bulletin_semestre["numero"], int)
assert isinstance(bulletin_semestre["inscription"], str)
assert isinstance(bulletin_semestre["groupes"], list)
assert isinstance(bulletin_semestre["absences"], dict)
assert isinstance(bulletin_semestre["ECTS"], dict)
assert isinstance(bulletin_semestre["notes"], dict)
assert isinstance(bulletin_semestre["rang"], dict)
assert (
verify_fields(
bulletin_semestre["absences"], BULLETIN_SEMESTRE_ABSENCES_FIELDS
)
is True
)
assert isinstance(bulletin_semestre["absences"]["injustifie"], int)
assert isinstance(bulletin_semestre["absences"]["total"], int)
assert (
verify_fields(bulletin_semestre["ECTS"], BULLETIN_SEMESTRE_ECTS_FIELDS)
is True
)
assert isinstance(bulletin_semestre["ECTS"]["acquis"], int)
assert isinstance(bulletin_semestre["ECTS"]["total"], float)
assert (
verify_fields(bulletin_semestre["notes"], BULLETIN_SEMESTRE_NOTES_FIELDS)
is True
)
assert isinstance(bulletin_semestre["notes"]["value"], str)
assert isinstance(bulletin_semestre["notes"]["min"], str)
assert isinstance(bulletin_semestre["notes"]["max"], str)
assert isinstance(bulletin_semestre["notes"]["moy"], str)
assert (
verify_fields(bulletin_semestre["rang"], BULLETIN_SEMESTRE_RANG_FIELDS)
is True
)
assert isinstance(bulletin_semestre["rang"]["value"], str)
assert isinstance(bulletin_semestre["rang"]["total"], int)
# # jury
# def test_jury():
@ -101,6 +488,141 @@ def test_bulletins(api_headers):
# assert r.status_code == 200
def test_formsemestre_etudiants(api_headers):
"""
Route: /formsemestre/<int:formsemestre_id>/etudiants,
/formsemestre/<int:formsemestre_id>/etudiants/demissionnaires,
/formsemestre/<int:formsemestre_id>/etudiants/defaillants
"""
formsemestre_id = 1
r = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
formsemestre_etus = r.json()
assert isinstance(formsemestre_etus, list)
for etu in formsemestre_etus:
assert verify_fields(etu, FORMSEMESTRE_ETUS_FIELDS) is True
assert isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
assert isinstance(etu["nom"], str)
assert etu["nom_usuel"] is None or isinstance(etu["nom_usuel"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["civilite"], str)
assert isinstance(etu["groups"], list)
etu_groups = etu["groups"]
for group in etu_groups:
assert isinstance(group["partition_id"], int)
assert isinstance(group["id"], int)
assert isinstance(group["formsemestre_id"], int)
assert group["partition_name"] is None or isinstance(
group["partition_name"], str
)
assert isinstance(group["numero"], int)
assert isinstance(group["bul_show_rank"], bool)
assert isinstance(group["show_in_lists"], bool)
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
### demissionnaires ###
r_demissionnaires = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}/etudiants/demissionnaires",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_demissionnaires.status_code == 200
formsemestre_etus = r_demissionnaires.json()
assert isinstance(formsemestre_etus, list)
for etu in formsemestre_etus:
assert verify_fields(etu, FORMSEMESTRE_ETUS_FIELDS) is True
assert isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
assert isinstance(etu["nom"], str)
assert etu["nom_usuel"] is None or isinstance(etu["nom_usuel"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["civilite"], str)
assert isinstance(etu["groups"], list)
etu_groups = etu["groups"]
for group in etu_groups:
assert isinstance(group["partition_id"], int)
assert isinstance(group["id"], int)
assert isinstance(group["formsemestre_id"], int)
assert group["partition_name"] is None or isinstance(
group["partition_name"], str
)
assert isinstance(group["numero"], int)
assert isinstance(group["bul_show_rank"], bool)
assert isinstance(group["show_in_lists"], bool)
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
### defaillants ###
r_defaillants = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}/etudiants/defaillants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_defaillants.status_code == 200
formsemestre_etus = r_defaillants.json()
assert isinstance(formsemestre_etus, list)
for etu in formsemestre_etus:
assert verify_fields(etu, FORMSEMESTRE_ETUS_FIELDS) is True
assert isinstance(etu["id"], int)
assert isinstance(etu["nip"], str)
assert isinstance(etu["ine"], str)
assert isinstance(etu["nom"], str)
assert etu["nom_usuel"] is None or isinstance(etu["nom_usuel"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["civilite"], str)
assert isinstance(etu["groups"], list)
etu_groups = etu["groups"]
for group in etu_groups:
assert isinstance(group["partition_id"], int)
assert isinstance(group["id"], int)
assert isinstance(group["formsemestre_id"], int)
assert group["partition_name"] is None or isinstance(
group["partition_name"], str
)
assert isinstance(group["numero"], int)
assert isinstance(group["bul_show_rank"], bool)
assert isinstance(group["show_in_lists"], bool)
assert isinstance(group["group_id"], int)
assert group["group_name"] is None or isinstance(group["group_name"], int)
assert r.json() != r_demissionnaires.json()
assert r.json() != r_defaillants.json()
assert r_demissionnaires.json() != r_defaillants.json()
### ERROR ###
id_formsemestre_inexistant = 265165689619851621685
r_error = requests.get(
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error.status_code == 404
r_error_demissionnaires = requests.get(
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/demissionnaires",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error_demissionnaires.status_code == 404
r_error_defaillants = requests.get(
f"{API_URL}/formsemestre/{id_formsemestre_inexistant}/etudiants/defaillants",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_error_defaillants.status_code == 404
def test_formsemestre_programme(api_headers):
"""
Route: /formsemestre/1/programme
@ -131,3 +653,122 @@ def test_formsemestre_programme(api_headers):
assert verify_fields(modules[0], MODIMPL_FIELDS)
assert verify_fields(ressource, MODIMPL_FIELDS)
assert verify_fields(sae, MODIMPL_FIELDS)
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
etat_evals = r.json()
assert len(etat_evals) == 3
for ue in etat_evals.values():
for module in ue:
assert isinstance(module["id"], int)
assert isinstance(module["titre"], str)
assert isinstance(module["evaluations"], list)
for eval in module["evaluations"]:
assert verify_fields(eval, EVAL_FIELDS)
assert isinstance(eval["id"], int)
assert eval["description"] is None or isinstance(
eval["description"], str
)
assert eval["datetime_epreuve"] is None or isinstance(
eval["datetime_epreuve"], str
)
assert isinstance(eval["heure_fin"], str)
assert isinstance(eval["coefficient"], float)
assert isinstance(eval["comptee"], str)
assert isinstance(eval["inscrits"], int)
assert isinstance(eval["manquantes"], int)
assert isinstance(eval["ABS"], int)
assert isinstance(eval["ATT"], int)
assert isinstance(eval["EXC"], int)
assert isinstance(eval["saisie_notes"], dict)
list_eval_id = [e["id"] for e in module["evaluations"]]
all_unique = True
for id in list_eval_id:
if list_eval_id.count(id) > 1:
all_unique = False
assert all_unique is True
saisie_notes = eval["saisie_notes"]
assert verify_fields(saisie_notes, SAISIE_NOTES_FIELDS)
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
eval["saisie_notes"]["datetime_debut"], str
)
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
eval["saisie_notes"]["datetime_fin"], str
)
assert eval["saisie_notes"]["datetime_debut"] is None or isinstance(
eval["saisie_notes"]["datetime_mediane"], str
)
if (
eval["saisie_notes"]["datetime_fin"] is not None
and eval["saisie_notes"]["datetime_mediane"] is not None
and eval["saisie_notes"]["datetime_debut"] is not None
):
assert (
eval["saisie_notes"]["datetime_fin"]
> eval["saisie_notes"]["datetime_mediane"]
)
assert (
eval["saisie_notes"]["datetime_fin"]
> eval["saisie_notes"]["datetime_debut"]
)
assert (
eval["saisie_notes"]["datetime_mediane"]
> eval["saisie_notes"]["datetime_debut"]
)
list_id_ue1 = []
list_titre_ue1 = []
list_id_ue2 = []
list_titre_ue2 = []
list_id_ue3 = []
list_titre_ue3 = []
i = 0
for ue in etat_evals.values():
i += 1
for module in ue:
if i == 1:
list_id_ue1.append(module["id"])
list_titre_ue1.append(module["id"])
elif i == 2:
list_id_ue2.append(module["id"])
list_titre_ue2.append(module["id"])
elif i == 3:
list_id_ue3.append(module["id"])
list_titre_ue3.append(module["id"])
assert list_id_ue1 != list_id_ue2
assert list_id_ue1 != list_titre_ue3
assert list_id_ue2 != list_titre_ue3
assert list_titre_ue1 != list_titre_ue2
assert list_titre_ue1 != list_titre_ue3
assert list_titre_ue2 != list_titre_ue3
##### ERROR #####
fake_eval_id = 153165161656849846516511321651651
r = requests.get(
f"{API_URL}/formsemestre/{fake_eval_id}/etat_evals",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Test API Jurys XXX TODO A ECRIRE
"""Test Logos
Utilisation :
créer les variables d'environnement: (indiquer les valeurs
@ -24,10 +24,13 @@ from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
def test_jury_preparation(api_headers):
"""
Route:
Test 'jury_preparation'
Route :
- /jury/formsemestre/<int:formsemestre_id>/preparation_jury
"""
r = requests.get(
SCODOC_URL
API_URL
+ "/ScoDoc/api/jury/formsemestre/<int:formsemestre_id>/preparation_jury",
headers=api_headers,
verify=CHECK_CERTIFICATE,
@ -37,7 +40,10 @@ def test_jury_preparation(api_headers):
def test_jury_decisions(api_headers):
"""
Route:
Test 'jury_decisions'
Route :
- /jury/formsemestre/<int:formsemestre_id>/decisions_jury
"""
r = requests.get(
API_URL + "/jury/formsemestre/<int:formsemestre_id>/decisions_jury",
@ -45,62 +51,3 @@ def test_jury_decisions(api_headers):
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# set_decision_jury
def test_set_decision_jury(api_headers):
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/jury/set_decision/etudid?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/jury/set_decision/nip?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/jury/set_decision/ine?etudid=<int:etudid>&formsemestre_id=<int:formesemestre_id>"
"&jury=<string:decision_jury>&devenir=<string:devenir_jury>&assiduite=<bool>",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# def test_annule_decision_jury(api_headers):
# """
# Route:
# """
# r = requests.get(
# SCODOC_URL
# + "/ScoDoc/api/jury/etudid/<int:etudid>/formsemestre/<int:formsemestre_id>/annule_decision",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# r = requests.get(
# SCODOC_URL
# + "/ScoDoc/api/jury/nip/<int:nip>/formsemestre/<int:formsemestre_id>/annule_decision",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# r = requests.get(
# SCODOC_URL
# + "/ScoDoc/api/jury/ine/<int:ine>/formsemestre/<int:formsemestre_id>/annule_decision",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200

View File

@ -20,103 +20,164 @@ Utilisation :
import requests
from tests.api.setup_test_api import API_URL, CHECK_CERTIFICATE, api_headers
from tests.api.tools_test_api import verify_fields
from tests.api.tools_test_api import (
verify_fields,
PARTITIONS_FIELDS,
PARTITIONS_GROUPS_ETU_FIELDS,
)
def test_partition(api_headers):
"""
Route:
"""
fields = [
"partition_id",
"id",
"formsemestre_id",
"partition_name",
"numero",
"bul_show_rank",
"show_in_lists",
]
Test 'partition'
Route :
- /partitions/<int:formsemestre_id>
"""
partition_id = 1
r = requests.get(
API_URL + "/partitions/1",
f"{API_URL}/partitions/{partition_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
partitions = r.json()
assert len(partitions) == 1
assert isinstance(partitions, list)
partition = partitions[0]
fields_ok = verify_fields(partition, fields)
assert fields_ok is True
assert isinstance(partition, dict)
assert verify_fields(partition, PARTITIONS_FIELDS) is True
assert partition_id == partition["partition_id"]
assert isinstance(partition["partition_id"], int)
assert isinstance(partition["id"], int)
assert isinstance(partition["formsemestre_id"], int)
assert partition["partition_name"] is None or isinstance(
partition["partition_name"], str
)
assert isinstance(partition["numero"], int)
assert isinstance(partition["bul_show_rank"], bool)
assert isinstance(partition["show_in_lists"], bool)
def test_etud_in_group(api_headers):
"""
Route:
"""
fields = [
"etudid",
"id",
"dept_id",
"nom",
"prenom",
"nom_usuel",
"civilite",
"date_naissance",
"lieu_naissance",
"dept_naissance",
"nationalite",
"statut",
"boursier",
"photo_filename",
"code_nip",
"code_ine",
"scodoc7_id",
"email",
"emailperso",
"domicile",
"codepostaldomicile",
"villedomicile",
"paysdomicile",
"telephone",
"telephonemobile",
"fax",
"typeadresse",
"description",
"group_id",
"etat",
"civilite_str",
"nom_disp",
"nomprenom",
"ne",
"email_default",
]
Test 'etud_in_group'
Routes :
- /partition/group/<int:group_id>
- /partition/group/<int:group_id>/etat/<string:etat>
"""
group_id = 1
r = requests.get(
API_URL + "/partitions/groups/1",
f"{API_URL}/partition/group/{group_id}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
etu = r.json()[0]
fields_ok = verify_fields(etu, fields)
assert r.status_code == 200
assert len(r.json()) == 16
assert fields_ok is True
# r = requests.get(
# API_URL + "/partitions/groups/1/etat/<string:etat>",
# headers=api_headers,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
assert isinstance(r.json(), list)
for etu in r.json():
assert verify_fields(etu, PARTITIONS_GROUPS_ETU_FIELDS)
assert isinstance(etu["etudid"], int)
assert isinstance(etu["id"], int)
assert isinstance(etu["dept_id"], int)
assert isinstance(etu["nom"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["nom_usuel"], str)
assert isinstance(etu["civilite"], str)
assert etu["date_naissance"] is None or isinstance(etu["date_naissance"], str)
assert etu["lieu_naissance"] is None or isinstance(etu["lieu_naissance"], str)
assert etu["dept_naissance"] is None or isinstance(etu["dept_naissance"], str)
assert etu["nationalite"] is None or isinstance(etu["nationalite"], str)
assert etu["statut"] is None or isinstance(etu["statut"], str)
assert etu["boursier"] is None or isinstance(etu["boursier"], bool)
assert etu["photo_filename"] is None or isinstance(etu["photo_filename"], str)
assert isinstance(etu["code_nip"], str)
assert isinstance(etu["code_ine"], str)
assert etu["scodoc7_id"] is None or isinstance(etu["scodoc7_id"], int)
assert isinstance(etu["email"], str)
assert etu["emailperso"] is None or isinstance(etu["emailperso"], str)
assert etu["domicile"] is None or isinstance(etu["domicile"], str)
assert etu["codepostaldomicile"] is None or isinstance(
etu["codepostaldomicile"], str
)
assert etu["villedomicile"] is None or isinstance(etu["villedomicile"], str)
assert etu["paysdomicile"] is None or isinstance(etu["paysdomicile"], str)
assert etu["telephone"] is None or isinstance(etu["telephone"], str)
assert etu["telephonemobile"] is None or isinstance(etu["telephonemobile"], str)
assert etu["fax"] is None or isinstance(etu["fax"], str)
assert isinstance(etu["typeadresse"], str)
assert etu["description"] is None or isinstance(etu["description"], int)
assert isinstance(etu["group_id"], int)
assert isinstance(etu["etat"], str)
assert isinstance(etu["civilite_str"], str)
assert isinstance(etu["nom_disp"], str)
assert isinstance(etu["nomprenom"], str)
assert isinstance(etu["ne"], str)
assert isinstance(etu["email_default"], str)
etat = "I"
r_etat = requests.get(
f"{API_URL}/partition/group/{group_id}/etat/{etat}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r_etat.status_code == 200
assert isinstance(r_etat.json(), list)
for etu in r_etat.json():
assert verify_fields(etu, PARTITIONS_GROUPS_ETU_FIELDS)
assert isinstance(etu["etudid"], int)
assert isinstance(etu["id"], int)
assert isinstance(etu["dept_id"], int)
assert isinstance(etu["nom"], str)
assert isinstance(etu["prenom"], str)
assert isinstance(etu["nom_usuel"], str)
assert isinstance(etu["civilite"], str)
assert etu["date_naissance"] is None or isinstance(etu["date_naissance"], str)
assert etu["lieu_naissance"] is None or isinstance(etu["lieu_naissance"], str)
assert etu["dept_naissance"] is None or isinstance(etu["dept_naissance"], str)
assert etu["nationalite"] is None or isinstance(etu["nationalite"], str)
assert etu["statut"] is None or isinstance(etu["statut"], str)
assert etu["boursier"] is None or isinstance(etu["boursier"], bool)
assert etu["photo_filename"] is None or isinstance(etu["photo_filename"], str)
assert isinstance(etu["code_nip"], str)
assert isinstance(etu["code_ine"], str)
assert etu["scodoc7_id"] is None or isinstance(etu["scodoc7_id"], int)
assert isinstance(etu["email"], str)
assert etu["emailperso"] is None or isinstance(etu["emailperso"], str)
assert etu["domicile"] is None or isinstance(etu["domicile"], str)
assert etu["codepostaldomicile"] is None or isinstance(
etu["codepostaldomicile"], str
)
assert etu["villedomicile"] is None or isinstance(etu["villedomicile"], str)
assert etu["paysdomicile"] is None or isinstance(etu["paysdomicile"], str)
assert etu["telephone"] is None or isinstance(etu["telephone"], str)
assert etu["telephonemobile"] is None or isinstance(etu["telephonemobile"], str)
assert etu["fax"] is None or isinstance(etu["fax"], str)
assert isinstance(etu["typeadresse"], str)
assert etu["description"] is None or isinstance(etu["description"], int)
assert isinstance(etu["group_id"], int)
assert isinstance(etu["etat"], str)
assert isinstance(etu["civilite_str"], str)
assert isinstance(etu["nom_disp"], str)
assert isinstance(etu["nomprenom"], str)
assert isinstance(etu["ne"], str)
assert isinstance(etu["email_default"], str)
assert etat == etu["etat"]
# # set_groups
# def test_set_groups(api_headers):
# """
# Route:
# Test 'set_groups'
#
# Routes :
# - /partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>/delete/<string:groups_to_delete>"
# "/create/<string:groups_to_create>
# """
# r = requests.get(
# SCODOC_URL

View File

@ -29,7 +29,7 @@ def test_permissions(api_headers):
# Ce test va récupérer toutes les routes de l'API
app = create_app(RunningConfig)
assert app
# Les routes de l'API avec GET, excluant les logos pour le momeent XXX
# Les routes de l'API avec GET, excluant les logos pour le moment XXX
api_rules = [
r
for r in app.url_map.iter_rules()

View File

@ -1,5 +1,6 @@
"""Utilitaires pour les tests de l'API
"""
import json
def verify_fields(json_response: dict, expected_fields: set) -> bool:
@ -14,6 +15,40 @@ def verify_fields(json_response: dict, expected_fields: set) -> bool:
return all(field in json_response for field in expected_fields)
def verify_occurences_ids_etus(json_response) -> bool:
"""
Vérifie si il n'y a pas deux fois le même id dans la liste d'étudiant donnée en paramètres
json_response : la réponse de la requête
Retourne True ou False
"""
list_etu = json.loads(json_response)
list_ids = [etu["id"] for etu in list_etu]
list_nip = [etu["nip"] for etu in list_etu]
list_ine = [etu["ine"] for etu in list_etu]
for id in list_ids:
if list_ids.count(id) > 1:
return False
for nip in list_nip:
if list_nip.count(nip) > 1:
return False
for ine in list_ine:
if list_ine.count(ine) > 1:
return False
return True
DEPARTEMENT_FIELDS = [
"id",
"acronym",
"description",
"visible",
"date_creation",
]
ETUD_FIELDS = {
"boursier",
"civilite",
@ -43,12 +78,12 @@ ETUD_FIELDS = {
}
FORMATION_FIELDS = {
"id",
"dept_id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"id",
"titre",
"version",
"type_parcours",
@ -56,6 +91,92 @@ FORMATION_FIELDS = {
"formation_id",
}
FORMATION_EXPORT_FIELDS = {
"dept_id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
"ue",
}
FORMATION_EXPORT_UE_FIELDS = {
"acronyme",
"numero",
"titre",
"type",
"ue_code",
"ects",
"is_external",
"code_apogee",
"coefficient",
"semestre_idx",
"color",
"reference",
"matiere",
}
FORMATION_EXPORT_UE_MATIERE_FIELDS = {
"titre",
"numero",
"module",
}
FORMATION_EXPORT_UE_MATIERE_MODULE_FIELDS = {
"titre",
"abbrev",
"code",
"heures_cours",
"heures_td",
"coefficient",
"ects",
"semestre_id",
"numero",
"code_apogee",
"module_type",
"coefficients",
}
FORMATION_EXPORT_UE_MATIERE_MODULE_COEF_FIELDS = {
"ue_reference",
"coef",
}
FORMSEMESTRE_FIELDS = [
"titre",
"gestion_semestrielle",
"scodoc7_id",
"date_debut",
"bul_bgcolor",
"date_fin",
"resp_can_edit",
"dept_id",
"etat",
"resp_can_change_ens",
"id",
"modalite",
"ens_can_edit_eval",
"formation_id",
"gestion_compensation",
"elt_sem_apo",
"semestre_id",
"bul_hide_xml",
"elt_annee_apo",
"block_moyennes",
"formsemestre_id",
"titre_num",
"titre_formation",
"date_debut_iso",
"date_fin_iso",
"responsables",
]
FSEM_FIELDS = {
"block_moyennes",
"bul_bgcolor",
@ -131,3 +252,468 @@ UE_FIELDS = {
"color",
"ue_id",
}
BULLETIN_FIELDS = {
"version",
"type",
"date",
"publie",
"etudiant",
"formation",
"formsemestre_id",
"etat_inscription",
"options",
"ressources",
"saes",
"ues",
"semestre",
}
BULLETIN_ETUDIANT_FIELDS = {
"civilite",
"code_ine",
"code_nip",
"date_naissance",
"dept_id",
"dept_acronym",
"email",
"emailperso",
"etudid",
"nom",
"prenom",
"nomprenom",
"lieu_naissance",
"dept_naissance",
"nationalite",
"boursier",
"fiche_url",
"photo_url",
"id",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
}
BULLETIN_FORMATION_FIELDS = {"id", "acronyme", "titre_officiel", "titre"}
BULLETIN_OPTIONS_FIELDS = {
"show_abs",
"show_abs_modules",
"show_ects",
"show_codemodules",
"show_matieres",
"show_rangs",
"show_ue_rangs",
"show_mod_rangs",
"show_moypromo",
"show_minmax",
"show_minmax_mod",
"show_minmax_eval",
"show_coef",
"show_ue_cap_details",
"show_ue_cap_current",
"show_temporary",
"temporary_txt",
"show_uevalid",
"show_date_inscr",
}
BULLETIN_RESSOURCES_FIELDS = {
"R101",
"R102",
"R103",
"R104",
"R105",
"R106",
"R107",
"R108",
"R109",
"R110",
"R111",
"R112",
"R113",
"R114",
"R115",
}
BULLETIN_SAES_FIELDS = {
"SAE11",
"SAE12",
"SAE13",
"SAE14",
"SAE15",
"SAE16",
}
########### RESSOURCES ET SAES ###########
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_FIELDS = {
"id",
"titre",
"code_apogee",
"url",
"moyenne",
"evaluations",
}
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_FIELDS = {
"id",
"description",
"date",
"heure_debut",
"heure_fin",
"coef",
"poids",
"note",
"url",
}
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_POIDS_FIELDS = {
"RT1.1",
"RT2.1",
"RT3.1",
}
BULLETIN_RESSOURCES_ET_SAES_RESSOURCE_ET_SAE_EVALUATION_NOTE_FIELDS = {
"value",
"min",
"max",
"moy",
}
########### UES ###########
BULLETIN_UES_FIELDS = {"RT1.1", "RT2.1", "RT3.1"}
BULLETIN_UES_UE_FIELDS = {
"id",
"titre",
"numero",
"type",
"color",
"competence",
"moyenne",
"bonus",
"malus",
"capitalise",
"ressources",
"saes",
"ECTS",
}
BULLETIN_UES_UE_MOYENNE_FIELDS = {"value", "min", "max", "moy", "rang", "total"}
BULLETIN_UES_RT11_RESSOURCES_FIELDS = {
"R101",
"R102",
"R103",
"R104",
"R106",
"R108",
"R110",
"R111",
"R112",
"R113",
"R114",
}
BULLETIN_UES_RT21_RESSOURCES_FIELDS = {
"R101",
"R103",
"R104",
"R105",
"R110",
"R111",
"R112",
"R113",
"R114",
"R115",
}
BULLETIN_UES_RT31_RESSOURCES_FIELDS = {
"R101",
"R107",
"R108",
"R109",
"R110",
"R111",
"R112",
"R115",
}
BULLETIN_UES_UE_RESSOURCES_RESSOURCE_FIELDS = {"id", "coef", "moyenne"}
BULLETIN_UES_RT11_SAES_FIELDS = {
"SAE11",
"SAE12",
}
BULLETIN_UES_RT21_SAES_FIELDS = {"SAE13"}
BULLETIN_UES_RT31_SAES_FIELDS = {
"SAE14",
"SAE15",
}
BULLETIN_UES_UE_SAES_SAE_FIELDS = {"id", "coef", "moyenne"}
BULLETIN_UES_UE_ECTS_FIELDS = {"acquis", "total"}
########### SEMESTRE ###########
BULLETIN_SEMESTRE_FIELDS = {
"etapes",
"date_debut",
"date_fin",
"annee_universitaire",
"numero",
"inscription",
"groupes",
"absences",
"ECTS",
"notes",
"rang",
}
BULLETIN_SEMESTRE_ABSENCES_FIELDS = {"injustifie", "total"}
BULLETIN_SEMESTRE_ECTS_FIELDS = {"acquis", "total"}
BULLETIN_SEMESTRE_NOTES_FIELDS = {"value", "min", "moy", "max"}
BULLETIN_SEMESTRE_RANG_FIELDS = {"value", "total"}
EVAL_FIELDS = {
"id",
"description",
"datetime_epreuve",
"heure_fin",
"coefficient",
"comptee",
"inscrits",
"manquantes",
"ABS",
"ATT",
"EXC",
"saisie_notes",
}
SAISIE_NOTES_FIELDS = {"datetime_debut", "datetime_fin", "datetime_mediane"}
REF_COMP_FIELDS = {
"dept_id",
"annexe",
"specialite",
"specialite_long",
"type_structure",
"type_departement",
"type_titre",
"version_orebut",
"scodoc_date_loaded",
"scodoc_orig_filename",
"competences",
"parcours",
}
ABSENCES_FIELDS = {
"jour",
"matin",
"estabs",
"estjust",
"description",
"begin",
"end",
}
ABSENCES_GROUP_ETAT_FIELDS = {"etudid", "list_abs"}
FORMSEMESTRE_ETUS_FIELDS = {
"id",
"nip",
"ine",
"nom",
"nom_usuel",
"prenom",
"civilite",
"groups",
}
FORMSEMESTRE_ETUS_GROUPS_FIELDS = {
"partition_id",
"id",
"formsemestre_id",
"partition_name",
"numero",
"bul_show_rank",
"show_in_lists",
"group_id",
"group_name",
}
EVALUATIONS_FIELDS = {
"id",
"jour",
"heure_fin",
"note_max",
"visibulletin",
"evaluation_type",
"moduleimpl_id",
"heure_debut",
"description",
"coefficient",
"publish_incomplete",
"numero",
"evaluation_id",
"date_debut",
"date_fin",
"poids",
"jouriso",
"duree",
"descrheure",
"matin",
"apresmidi",
}
EVALUATION_FIELDS = {
"id",
"etudid",
"evaluation_id",
"value",
"comment",
"date",
"uid",
}
PARTITIONS_FIELDS = {
"partition_id",
"id",
"formsemestre_id",
"partition_name",
"numero",
"bul_show_rank",
"show_in_lists",
}
PARTITIONS_GROUPS_ETU_FIELDS = {
"etudid",
"id",
"dept_id",
"nom",
"prenom",
"nom_usuel",
"civilite",
"date_naissance",
"lieu_naissance",
"dept_naissance",
"nationalite",
"statut",
"boursier",
"photo_filename",
"code_nip",
"code_ine",
"scodoc7_id",
"email",
"emailperso",
"domicile",
"codepostaldomicile",
"villedomicile",
"paysdomicile",
"telephone",
"telephonemobile",
"fax",
"typeadresse",
"description",
"group_id",
"etat",
"civilite_str",
"nom_disp",
"nomprenom",
"ne",
"email_default",
}
FORMSEMESTRE_BULLETINS_FIELDS = {
"version",
"type",
"date",
"publie",
"etudiant",
"formation",
"formsemestre_id",
"etat_inscription",
"options",
"ressources",
"saes",
"ues",
"semestre",
}
FORMSEMESTRE_BULLETINS_ETU_FIELDS = {
"civilite",
"code_ine",
"code_nip",
"date_naissance",
"dept_id",
"dept_acronym",
"email",
"emailperso",
"etudid",
"nom",
"prenom",
"nomprenom",
"lieu_naissance",
"dept_naissance",
"nationalite",
"boursier",
"fiche_url",
"photo_url",
"id",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
}
FORMSEMESTRE_BULLETINS_FORMATION_FIELDS = {
"id",
"acronyme",
"titre_officiel",
"titre",
}
FORMSEMESTRE_BULLETINS_OPT_FIELDS = {
"show_abs",
"show_abs_modules",
"show_ects",
"show_codemodules",
"show_matieres",
"show_rangs",
"show_ue_rangs",
"show_mod_rangs",
"show_moypromo",
"show_minmax",
"show_minmax_mod",
"show_minmax_eval",
"show_coef",
"show_ue_cap_details",
"show_ue_cap_current",
"show_temporary",
"temporary_txt",
"show_uevalid",
"show_date_inscr",
}

View File

@ -10,7 +10,7 @@
FLASK_DEBUG=1
2) En tant qu'utilisateur scodoc, lancer:
tools/create_database.sh SCODOC_TEST_API
tools/create_database.sh
flask db upgrade
flask sco-db-init --erase
flask init-test-database
@ -24,12 +24,32 @@
"""
import datetime
import random
import time
import sys
from app.auth.models import Role, User
from app import models
from app.models import Departement, Formation, FormSemestre, Identite
from app.models import (
Departement,
Formation,
FormSemestre,
Identite,
ModuleImpl,
NotesNotes,
ApcReferentielCompetences,
ApcCompetence,
Absence,
FormSemestreEtape,
)
from app import db
from app.models.but_refcomp import (
ApcParcours,
ApcAnneeParcours,
ApcSituationPro,
ApcComposanteEssentielle,
ApcNiveau,
ApcAppCritique,
)
from app.scodoc import (
sco_cache,
sco_evaluation_db,
@ -38,6 +58,7 @@ from app.scodoc import (
sco_groups,
)
from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_saisie_notes import notes_add
from tools.fakeportal.gen_nomprenoms import nomprenom
random.seed(12345678) # tests reproductibles
@ -160,13 +181,31 @@ def create_formsemestre(
def inscrit_etudiants(etuds: list, formsemestre: FormSemestre):
"""Inscrit les etudiants aux semestres et à tous ses modules"""
for etud in etuds:
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
formsemestre.id,
etud.id,
group_ids=[],
etat="I",
method="init db test",
)
aleatoire = random.randint(0, 10)
if aleatoire <= 3:
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
formsemestre.id,
etud.id,
group_ids=[],
etat="I",
method="init db test",
)
elif 3 < aleatoire <= 6:
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
formsemestre.id,
etud.id,
group_ids=[],
etat="D",
method="init db test",
)
else:
sco_formsemestre_inscriptions.do_formsemestre_inscription_with_modules(
formsemestre.id,
etud.id,
group_ids=[],
etat="DEF",
method="init db test",
)
def create_evaluations(formsemestre: FormSemestre):
@ -188,6 +227,286 @@ def create_evaluations(formsemestre: FormSemestre):
evaluation_id = sco_evaluation_db.do_evaluation_create(**args)
def saisie_notes_evaluations(formsemestre: FormSemestre, user: User):
"""
Saisie les notes des evaluations d'un semestre
"""
etuds = formsemestre.etuds
list_etuds = []
for etu in etuds:
list_etuds.append(etu)
date_debut = formsemestre.date_debut
date_fin = formsemestre.date_fin
list_ues = formsemestre.query_ues()
def saisir_notes(evaluation_id: int, condition: int):
"""
Permet de saisir les notes de manière aléatoire suivant une condition
Définition des valeurs de condition :
0 : all_notes_saisies
1 : all_notes_manquantes
2 : some_notes_manquantes
"""
if condition == 0 or condition == 2:
if condition == 0:
for etu in list_etuds:
note = NotesNotes(
etu.id,
evaluation_id,
random.uniform(0, 20),
"",
date_debut + random.random() * (date_fin - date_debut),
user.id,
)
db.session.add(note)
db.session.commit()
else:
percent = 80 / 100
len_etuds = len(list_etuds)
new_list_etuds = random.sample(list_etuds, k=int(percent * len_etuds))
for etu in new_list_etuds:
note = NotesNotes(
etu.id,
evaluation_id,
random.uniform(0, 20),
"",
date_debut + random.random() * (date_fin - date_debut),
user.id,
)
db.session.add(note)
db.session.commit()
for ue in list_ues:
mods = ue.modules
for mod in mods:
moduleimpl = ModuleImpl.query.get_or_404(mod.id)
for evaluation in moduleimpl.evaluations:
condition_saisie_notes = random.randint(0, 2)
saisir_notes(evaluation.id, condition_saisie_notes)
def create_ref_comp(formation: Formation):
"""
Créer un referentiel de competences
"""
# ### ApcSituationPro ###
# apc_situation_pro_id = 1
# apc_situation_pro_competence_id = 1
# apc_situation_pro_libelle = ""
#
# apc_situation_pro = ApcSituationPro(
# apc_situation_pro_id, apc_situation_pro_competence_id, apc_situation_pro_libelle
# )
# db.session.add(apc_situation_pro)
# db.session.commit()
#
# ### ApcComposanteEssentielle ###
# apc_composante_essentielle_id = 1
# apc_composante_essentielle_competence_id = 1
# apc_composante_essentielle_libelle = ""
#
# apc_composante_essentielle = ApcComposanteEssentielle(
# apc_composante_essentielle_id,
# apc_composante_essentielle_competence_id,
# apc_composante_essentielle_libelle,
# )
# db.session.add(apc_composante_essentielle)
# db.session.commit()
#
# ### ApcAppCritique ###
# apc_app_critique_id = 1
# apc_app_critique_niveau_id = 1
# apc_app_critique_code = ""
# apc_app_critique_libelle = ""
# apc_app_critique_modules = formation.modules
#
# apc_app_critique = ApcAppCritique(
# apc_app_critique_id,
# apc_app_critique_niveau_id,
# apc_app_critique_code,
# apc_app_critique_libelle,
# apc_app_critique_modules,
# )
# db.session.add(apc_app_critique)
# db.session.commit()
#
# ### ApcNiveau ###
# apc_niveau_id = 1
# apc_niveau_competence_id = 1
# apc_niveau_libelle = ""
# apc_niveau_annee = ""
# apc_niveau_ordre = 1
# apc_niveau_app_critiques = apc_app_critique
#
# apc_niveau = ApcNiveau(
# apc_niveau_id,
# apc_niveau_competence_id,
# apc_niveau_libelle,
# apc_niveau_annee,
# apc_niveau_ordre,
# apc_niveau_app_critiques,
# )
# db.session.add(apc_niveau)
# db.session.commit()
#
# ### ApcCompetence ###
# apc_competence_id = 1
# apc_competence_referentiel_id = 1
# apc_competence_id_orebut = ""
# apc_competence_titre = ""
# apc_competence_titre_long = ""
# apc_competence_couleur = ""
# apc_competence_numero = 1
# apc_competence_xml_attribs = { # xml_attrib : attribute
# "id": "id_orebut",
# "nom_court": "titre", # was name
# "libelle_long": "titre_long",
# }
# apc_competence_situations = apc_situation_pro
# apc_competence_composantes_essentielles = apc_composante_essentielle
# apc_competence_niveaux = apc_niveau
#
# apc_competence = ApcCompetence(
# apc_competence_id,
# apc_competence_referentiel_id,
# apc_competence_id_orebut,
# apc_competence_titre,
# apc_competence_titre_long,
# apc_competence_couleur,
# apc_competence_numero,
# apc_competence_xml_attribs,
# apc_competence_situations,
# apc_competence_composantes_essentielles,
# apc_competence_niveaux,
# )
# db.session.add(apc_competence)
# db.session.commit()
#
# ### ApcAnneeParcours ###
# apc_annee_parcours_id = 1
# apc_annee_parcours_parcours_id = 1
# apc_annee_parcours_ordre = 1
#
# ap_annee_parcours = ApcAnneeParcours(
# apc_annee_parcours_id, apc_annee_parcours_parcours_id, apc_annee_parcours_ordre
# )
#
# ### ApcParcours ###
# apc_parcours_id = 1
# apc_parcours_referentiel_id = 1
# apc_parcours_numero = 1
# apc_parcours_code = ""
# apc_parcours_libelle = ""
# apc_parcours_annees = ap_annee_parcours
#
# apc_parcours = ApcParcours(
# apc_parcours_id,
# apc_parcours_referentiel_id,
# apc_parcours_numero,
# apc_parcours_code,
# apc_parcours_libelle,
# apc_parcours_annees,
# )
# db.session.add(apc_parcours)
# db.session.commit()
### ApcReferentielCompetences ###
apc_referentiel_competences_id = 1
apc_referentiel_competences_dept_id = 1
apc_referentiel_competences_annexe = ""
apc_referentiel_competences_specialite = ""
apc_referentiel_competences_specialite_long = ""
apc_referentiel_competences_type_titre = ""
apc_referentiel_competences_type_structure = ""
apc_referentiel_competences_type_departement = ""
apc_referentiel_competences_version_orebut = ""
apc_referentiel_competences_xml_attribs = {
"type": "type_titre",
"version": "version_orebut",
}
apc_referentiel_competences_scodoc_date_loaded = ""
apc_referentiel_competences_scodoc_orig_filename = ""
# apc_referentiel_competences_competences = apc_competence
# apc_referentiel_competences_parcours = apc_parcours
# apc_referentiel_competences_formations = formation
apc_referentiel_competences = ApcReferentielCompetences(
apc_referentiel_competences_id,
apc_referentiel_competences_dept_id,
apc_referentiel_competences_annexe,
apc_referentiel_competences_specialite,
apc_referentiel_competences_specialite_long,
apc_referentiel_competences_type_titre,
apc_referentiel_competences_type_structure,
apc_referentiel_competences_type_departement,
apc_referentiel_competences_version_orebut,
apc_referentiel_competences_xml_attribs,
# apc_referentiel_competences_scodoc_date_loaded,
apc_referentiel_competences_scodoc_orig_filename,
# apc_referentiel_competences_competences,
# apc_referentiel_competences_parcours,
# apc_referentiel_competences_formations,
)
db.session.add(apc_referentiel_competences)
db.session.commit()
formation.referentiel_competence_id = apc_referentiel_competences.id
db.session.commit()
def add_absences(formsemestre: FormSemestre):
"""
Ajoute des absences en base
"""
date_debut = formsemestre.date_debut
date_fin = formsemestre.date_fin
etuds = formsemestre.etuds
id_db = 1
for etu in etuds:
aleatoire = random.randint(0, 1)
if aleatoire == 1:
nb_absences = random.randint(1, 5)
for absence in range(0, nb_absences):
id = id_db
etudid = etu.id
jour = date_debut + random.random() * (date_fin - date_debut)
estabs = True
estjust = True if random.randint(0, 1) == 1 else False
matin = True if random.randint(0, 1) == 1 else False
description = ""
abs = Absence(id, etudid, jour, estabs, estjust, matin, description)
db.session.add(abs)
db.session.commit()
id_db += 1
def create_etape_apo(formsemestre: FormSemestre):
"""
Ajoute étape apoge au formsemestre
"""
etape_apo1 = FormSemestreEtape(
id=1, formsemestre_id=formsemestre.id, etape_apo="A1"
)
db.session.add(etape_apo1)
etape_apo2 = FormSemestreEtape(
id=2, formsemestre_id=formsemestre.id, etape_apo="A2"
)
db.session.add(etape_apo2)
etape_apo3 = FormSemestreEtape(
id=3, formsemestre_id=formsemestre.id, etape_apo="A3"
)
db.session.add(etape_apo3)
list_etapes = [etape_apo1, etape_apo2, etape_apo3]
formsemestre.etapes = list_etapes
db.session.commit()
def init_test_database():
"""Appelé par la commande `flask init-test-database`
@ -201,6 +520,10 @@ def init_test_database():
formsemestre = create_formsemestre(formation, user_lecteur)
create_evaluations(formsemestre)
inscrit_etudiants(etuds, formsemestre)
saisie_notes_evaluations(formsemestre, user_lecteur)
create_ref_comp(formation)
add_absences(formsemestre)
create_etape_apo(formsemestre)
# à compléter
# - groupes
# - absences