This commit is contained in:
Emmanuel Viennet 2022-05-03 02:41:01 +02:00
commit da58e6c18c
13 changed files with 726 additions and 535 deletions

View File

@ -93,7 +93,7 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None):
"jour": "Fri, 15 Apr 2022 00:00:00 GMT",
"matin": false,
"estabs": true,
"estjust": false,
"estjust": true,
"description": "",
"begin": "2022-04-15 12:00:00",
"end": "2022-04-15 17:59:59"
@ -120,7 +120,11 @@ def absences_just(etudid: int = None, nip: int = None, ine: int = None):
@bp.route(
"/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
"/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_permission_required(Permission.APIView)

View File

@ -187,117 +187,3 @@ def referenciel_competences(dept: str, formation_id: int):
)
else:
return jsonify(ref_comp)
@bp.route(
"/departements/<string:dept>/formsemestre/<string:formsemestre_id>/programme",
methods=["GET"],
)
@token_permission_required(Permission.APIView)
def semestre_index(dept: str, formsemestre_id: int):
"""
Retourne la liste des Ues, ressources et SAE d'un semestre
dept : l'acronym d'un département
formsemestre_id : l'id d'un formesemestre
Exemple de résultat :
{
"ues": [
{
"type": 0,
"formation_id": 1,
"ue_code": "UCOD11",
"id": 1,
"ects": 12.0,
"acronyme": "RT1.1",
"is_external": false,
"numero": 1,
"code_apogee": "",
"titre": "Administrer les r\u00e9seaux et l\u2019Internet",
"coefficient": 0.0,
"semestre_idx": 1,
"color": "#B80004",
"ue_id": 1
},
...
],
"ressources": [
{
"titre": "Fondamentaux de la programmation",
"coefficient": 1.0,
"module_type": 2,
"id": 17,
"ects": null,
"abbrev": null,
"ue_id": 3,
"code": "R107",
"formation_id": 1,
"heures_cours": 0.0,
"matiere_id": 3,
"heures_td": 0.0,
"semestre_id": 1,
"heures_tp": 0.0,
"numero": 70,
"code_apogee": "",
"module_id": 17
},
...
],
"saes": [
{
"titre": "Se pr\u00e9senter sur Internet",
"coefficient": 1.0,
"module_type": 3,
"id": 14,
"ects": null,
"abbrev": null,
"ue_id": 3,
"code": "SAE14",
"formation_id": 1,
"heures_cours": 0.0,
"matiere_id": 3,
"heures_td": 0.0,
"semestre_id": 1,
"heures_tp": 0.0,
"numero": 40,
"code_apogee": "",
"module_id": 14
},
...
]
}
"""
app.set_sco_dept(dept)
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
ues = formsemestre.query_ues()
ues_dict = []
ressources = []
saes = []
for ue in ues:
ues_dict.append(ue.to_dict())
ressources = ue.get_ressources()
saes = ue.get_saes()
data_ressources = []
for ressource in ressources:
data_ressources.append(ressource.to_dict())
data_saes = []
for sae in saes:
data_saes.append(sae.to_dict())
data = {
"ues": ues_dict,
"ressources": data_ressources,
"saes": data_saes,
}
return data

View File

@ -22,31 +22,23 @@ def etudiants_courant(long=False):
Retourne la liste des étudiants courant
Exemple de résultat :
{
{
"civilite": "X",
"code_ine": null,
"code_nip": null,
"date_naissance": null,
"email": null,
"emailperso": null,
"etudid": 18,
[
{
"id": 1,
"nip": 1,
"nom": "MOREL",
"prenom": "JACQUES"
},
{
"prenom": "JACQUES",
"civilite": "X",
"code_ine": null,
"code_nip": null,
"date_naissance": null,
"email": null,
"emailperso": null,
"etudid": 19,
"nom": "FOURNIER",
"prenom": "ANNE"
},
...
}
},
{
"id": 2,
"nip": 2,
"nom": "GILLES",
"prenom": "MAXIME",
"civilite": "X",
},
...
]
"""
# Récupération de tous les étudiants
etuds = Identite.query.filter(
@ -59,7 +51,7 @@ def etudiants_courant(long=False):
data = [etud.to_dict_bul(include_urls=False) for etud in etuds]
else:
data = [etud.to_dict_short() for etud in etuds]
print(jsonify(data))
return jsonify(data)
@ -76,17 +68,32 @@ def etudiant(etudid: int = None, nip: int = None, ine: int = None):
ine : le code ine d'un étudiant
Exemple de résultat :
{
"civilite": "X",
"code_ine": null,
"code_nip": null,
"date_naissance": null,
"email": null,
"emailperso": null,
"etudid": 18,
"nom": "MOREL",
"prenom": "JACQUES"
}
{
"civilite": "X",
"code_ine": "1",
"code_nip": "1",
"date_naissance": "",
"email": "SACHA.COSTA@example.com",
"emailperso": "",
"etudid": 1,
"nom": "COSTA",
"prenom": "SACHA",
"nomprenom": "Sacha COSTA",
"lieu_naissance": "",
"dept_naissance": "",
"nationalite": "",
"boursier": "",
"id": 1,
"codepostaldomicile": "",
"paysdomicile": "",
"telephonemobile": "",
"typeadresse": "domicile",
"domicile": "",
"villedomicile": "",
"telephone": "",
"fax": "",
"description": ""
}
"""
# Récupération de l'étudiant
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)
@ -110,38 +117,36 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
ine : le code ine d'un étudiant
Exemple de résultat :
[
{
"titre": "master machine info",
"gestion_semestrielle": false,
"date_debut": "01/09/2021",
"bul_bgcolor": null,
"date_fin": "15/12/2022",
"resp_can_edit": false,
"dept_id": 1,
"etat": true,
"resp_can_change_ens": false,
"id": 1,
"modalite": "FI",
"ens_can_edit_eval": false,
"formation_id": 1,
"gestion_compensation": false,
"elt_sem_apo": null,
"semestre_id": 1,
"bul_hide_xml": false,
"elt_annee_apo": null,
"block_moyennes": false,
"formsemestre_id": 1,
"titre_num": "master machine info semestre 1",
"date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-12-15",
"responsables": [
3,
2
]
},
...
]
[
{
"date_fin": "31/08/2022",
"resp_can_edit": false,
"dept_id": 1,
"etat": true,
"resp_can_change_ens": true,
"id": 1,
"modalite": "FI",
"ens_can_edit_eval": false,
"formation_id": 1,
"gestion_compensation": false,
"elt_sem_apo": null,
"semestre_id": 1,
"bul_hide_xml": false,
"elt_annee_apo": null,
"titre": "Semestre test",
"block_moyennes": false,
"scodoc7_id": null,
"date_debut": "01/09/2021",
"gestion_semestrielle": false,
"bul_bgcolor": "white",
"formsemestre_id": 1,
"titre_num": "Semestre test semestre 1",
"date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-08-31",
"responsables": []
},
...
]
"""
# Récupération de l'étudiant
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)

View File

@ -62,27 +62,27 @@ def evaluation_notes(evaluation_id: int):
evaluation_id : l'id d'une évaluation
Exemple de résultat :
{
"1": {
"id": 1,
"etudid": 10,
"evaluation_id": 1,
"value": 15.0,
"comment": "",
"date": "Wed, 20 Apr 2022 06:49:05 GMT",
"uid": 2
},
"2": {
"id": 2,
"etudid": 1,
"evaluation_id": 1,
"value": 12.0,
"comment": "",
"date": "Wed, 20 Apr 2022 06:49:06 GMT",
"uid": 2
},
...
}
{
"1": {
"id": 1,
"etudid": 10,
"evaluation_id": 1,
"value": 15.0,
"comment": "",
"date": "Wed, 20 Apr 2022 06:49:05 GMT",
"uid": 2
},
"2": {
"id": 2,
"etudid": 1,
"evaluation_id": 1,
"value": 12.0,
"comment": "",
"date": "Wed, 20 Apr 2022 06:49:06 GMT",
"uid": 2
},
...
}
"""
# Fonction utilisée : app.scodoc.sco_evaluation_db.do_evaluation_get_all_notes()

View File

@ -32,7 +32,6 @@ def formations():
},
...
]
"""
# Récupération de toutes les formations
list_formations = models.Formation.query.all()
@ -171,13 +170,12 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False):
},
]
}
"""
# Fonction utilité : app.scodoc.sco_formations.formation_export()
try:
# Utilisation de la fonction formation_export
data = formation_export(formation_id)
data = formation_export(formation_id, export_ids)
except ValueError:
return error_response(
409,
@ -190,17 +188,47 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False):
@bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
@token_permission_required(Permission.APIView)
def moduleimpls(moduleimpl_id: int):
def moduleimpl(moduleimpl_id: int):
"""
Retourne la liste des moduleimpl
Retourne un module moduleimpl en fonction de son id
moduleimpl_id : l'id d'un moduleimpl
Exemple de résultat :
{
"id": 1,
"formsemestre_id": 1,
"computation_expr": null,
"module_id": 1,
"responsable_id": 2,
"moduleimpl_id": 1,
"ens": [],
"module": {
"heures_tp": 0,
"code_apogee": "",
"titre": "Initiation aux réseaux informatiques",
"coefficient": 1,
"module_type": 2,
"id": 1,
"ects": null,
"abbrev": "Init aux réseaux informatiques",
"ue_id": 1,
"code": "R101",
"formation_id": 1,
"heures_cours": 0,
"matiere_id": 1,
"heures_td": 0,
"semestre_id": 1,
"numero": 10,
"module_id": 1
}
}
"""
# Récupération des tous les moduleimpl
list_moduleimpls = models.ModuleImpl.query.filter_by(id=moduleimpl_id)
moduleimpl = models.ModuleImpl.query.filter_by(id=moduleimpl_id).first_or_404()
# Mise en forme des données
data = [moduleimpl.to_dict() for moduleimpl in list_moduleimpls]
data = moduleimpl.to_dict()
return jsonify(data)
@ -208,7 +236,7 @@ def moduleimpls(moduleimpl_id: int):
@bp.route(
"/formations/moduleimpl/formsemestre/<int:formsemestre_id>/liste",
methods=["GET"],
) # XXX TODO penser à changer la route sur la doc
)
@token_permission_required(Permission.APIView)
def moduleimpls_sem(formsemestre_id: int):
"""

View File

@ -68,6 +68,35 @@ def formsemestre_apo(etape_apo: str):
Retourne les informations sur les formsemestres
etape_apo : l'id d'une étape apogée
Exemple de résultat :
{
"date_fin": "31/08/2022",
"resp_can_edit": false,
"dept_id": 1,
"etat": true,
"resp_can_change_ens": true,
"id": 1,
"modalite": "FI",
"ens_can_edit_eval": false,
"formation_id": 1,
"gestion_compensation": false,
"elt_sem_apo": null,
"semestre_id": 1,
"bul_hide_xml": false,
"elt_annee_apo": null,
"titre": "Semestre test",
"block_moyennes": false,
"scodoc7_id": null,
"date_debut": "01/09/2021",
"gestion_semestrielle": false,
"bul_bgcolor": "white",
"formsemestre_id": 1,
"titre_num": "Semestre test semestre 1",
"date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-08-31",
"responsables": []
}
"""
formsemestres = FormSemestre.query.filter(
FormSemestreEtape.etape_apo == etape_apo,
@ -78,21 +107,20 @@ def formsemestre_apo(etape_apo: str):
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/etudid/<int:etudid>/bulletin",
"/formsemestre/<int:formsemestre_id>/etudiant/etudid/<int:etudid>/bulletin",
methods=["GET"],
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin",
"/formsemestre/<int:formsemestre_id>/etudiant/nip/<int:nip>/bulletin",
methods=["GET"],
)
@bp.route(
"/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin",
"/formsemestre/<int:formsemestre_id>/etudiant/ine/<int:ine>/bulletin",
methods=["GET"],
)
@token_permission_required(Permission.APIView)
def etudiant_bulletin(
formsemestre_id,
dept,
etudid: int = None,
nip: int = None,
ine: int = None,
@ -212,7 +240,15 @@ def etudiant_bulletin(
# Fonction utilisée : app.scodoc.sco_bulletins_json.make_json_formsemestre_bulletinetud()
try:
app.set_sco_dept(dept)
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
dept = models.Departement.query.filter_by(
id=formsemestre.dept_id
).first_or_404()
app.set_sco_dept(dept.acronym)
except:
return error_response(
409,
@ -470,3 +506,115 @@ def jury(formsemestre_id: int):
# )
return jsonify(data)
@bp.route(
"/formsemestre/<int:formsemestre_id>/programme",
methods=["GET"],
)
@token_permission_required(Permission.APIView)
def semestre_index(formsemestre_id: int):
"""
Retourne la liste des Ues, ressources et SAE d'un semestre
dept : l'acronym d'un département
formsemestre_id : l'id d'un formesemestre
Exemple de résultat :
{
"ues": [
{
"type": 0,
"formation_id": 1,
"ue_code": "UCOD11",
"id": 1,
"ects": 12.0,
"acronyme": "RT1.1",
"is_external": false,
"numero": 1,
"code_apogee": "",
"titre": "Administrer les r\u00e9seaux et l\u2019Internet",
"coefficient": 0.0,
"semestre_idx": 1,
"color": "#B80004",
"ue_id": 1
},
...
],
"ressources": [
{
"titre": "Fondamentaux de la programmation",
"coefficient": 1.0,
"module_type": 2,
"id": 17,
"ects": null,
"abbrev": null,
"ue_id": 3,
"code": "R107",
"formation_id": 1,
"heures_cours": 0.0,
"matiere_id": 3,
"heures_td": 0.0,
"semestre_id": 1,
"heures_tp": 0.0,
"numero": 70,
"code_apogee": "",
"module_id": 17
},
...
],
"saes": [
{
"titre": "Se pr\u00e9senter sur Internet",
"coefficient": 1.0,
"module_type": 3,
"id": 14,
"ects": null,
"abbrev": null,
"ue_id": 3,
"code": "SAE14",
"formation_id": 1,
"heures_cours": 0.0,
"matiere_id": 3,
"heures_td": 0.0,
"semestre_id": 1,
"heures_tp": 0.0,
"numero": 40,
"code_apogee": "",
"module_id": 14
},
...
]
}
"""
formsemestre = models.FormSemestre.query.filter_by(
id=formsemestre_id
).first_or_404()
ues = formsemestre.query_ues()
ues_dict = []
ressources = []
saes = []
for ue in ues:
ues_dict.append(ue.to_dict())
ressources = ue.get_ressources()
saes = ue.get_saes()
data_ressources = []
for ressource in ressources:
data_ressources.append(ressource.to_dict())
data_saes = []
for sae in saes:
data_saes.append(sae.to_dict())
data = {
"ues": ues_dict,
"ressources": data_ressources,
"saes": data_saes,
}
return data

View File

@ -121,13 +121,13 @@ def etud_in_group(group_id: int, etat=None):
@bp.route(
"/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&"
"groups_to_create=<int:groups_to_create>&groups_to_delete=<int:groups_to_delete>",
"/partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>/delete/<string:groups_to_delete>"
"/create/<string:groups_to_create>",
methods=["POST"],
)
@token_permission_required(Permission.APIEtudChangeGroups)
def set_groups(
partition_id: int, groups_lists: int, groups_to_delete: int, groups_to_create: int
partition_id: int, groups_lists: str, groups_to_delete: str, groups_to_create: str
):
"""
Set les groups

View File

@ -20,10 +20,18 @@ Utilisation :
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# departements
def test_departements(): #XXX TODO pour Seb
def test_departements():
fields = [
"id",
"acronym",
"description",
"visible",
"date_creation",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements",
headers=HEADERS,
@ -32,134 +40,122 @@ def test_departements(): #XXX TODO pour Seb
assert r.status_code == 200
assert len(r.json()) == 1
dept = r.json()[0]
fields_OK = verify_fields(dept, fields)
assert fields_OK is True
# liste_etudiants
def test_liste_etudiants(): #XXX TODO pour Seb
def test_liste_etudiants():
fields = [
"civilite",
"code_ine",
"code_nip",
"date_naissance",
"email",
"emailperso",
"etudid",
"nom",
"prenom",
"nomprenom",
"lieu_naissance",
"dept_naissance",
"nationalite",
"boursier",
"id",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste",
headers=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(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1",
headers=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
# liste_semestres_courant
def test_semestres_courant(): #XXX TODO pour Seb
def test_semestres_courant():
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",
"date_debut_iso",
"date_fin_iso",
"responsables",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
sem = r.json()[0]
fields_OK = verify_fields(sem, fields)
assert r.status_code == 200
assert len(r.json()) == 1
assert fields_OK is True
# referenciel_competences
def test_referenciel_competences():
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
SCODOC_URL
+ "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200 or 204
# semestre_index
def test_semestre_index(): #XXX TODO pour Seb
ue_fields = [
"semestre_idx",
"type",
"formation_id",
"ue_code",
"id",
"ects",
"acronyme",
"is_external",
"numero",
"code_apogee",
"titre",
"coefficient",
"color",
"ue_id",
]
ressource_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
sae_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 3
ue = r.json()["ues"][0]
ressource = r.json()["ressources"][0]
sae = r.json()["saes"][0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in ue:
if field not in ue_fields:
fields_OK = False
for field in ressource:
if field not in ressource_fields:
fields_OK = False
for field in sae:
if field not in sae_fields:
fields_OK = False
assert fields_OK is True

View File

@ -21,63 +21,38 @@ from random import randint
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# # etudiants
# def test_etudiants():
#
# fields = [
# "civilite",
# "code_ine",
# "code_nip",
# "date_naissance",
# "email",
# "emailperso",
# "etudid",
# "nom",
# "prenom",
# "nomprenom",
# "lieu_naissance",
# "dept_naissance",
# "nationalite",
# "boursier",
# "id",
# "domicile",
# "villedomicile",
# "telephone",
# "fax",
# "description",
# "codepostaldomicile",
# "paysdomicile",
# "telephonemobile",
# "typeadresse",
# ]
#
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/etudiants",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# assert len(r.json()) == 16
#
# # Choisis aléatoirement un étudiant dans la liste des étudiants
# etu = r.json()[randint(0, len(r.json())) - 1]
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in etu:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
from tests.api.tools_test_api import verify_fields
# etudiants_courant
def test_etudiants_courant(): # XXX TODO pour Seb
def test_etudiants_courant():
fields = [
"id",
"nip",
"nom",
"nom_usuel",
"prenom",
"civilite",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 16
# Choisis aléatoirement un étudiant dans la liste des étudiants
etu = r.json()[randint(0, len(r.json())) - 1]
fields_OK = verify_fields(etu, fields)
assert fields_OK is True
########## Version long################
fields_long = [
"civilite",
"code_ine",
"code_nip",
@ -93,19 +68,19 @@ def test_etudiants_courant(): # XXX TODO pour Seb
"nationalite",
"boursier",
"id",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
"domicile",
"villedomicile",
"telephone",
"fax",
"description",
"codepostaldomicile",
"paysdomicile",
"telephonemobile",
"typeadresse",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/etudiants/courant",
SCODOC_URL + "/ScoDoc/api/etudiants/courant/long",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -115,18 +90,13 @@ def test_etudiants_courant(): # XXX TODO pour Seb
# Choisis aléatoirement un étudiant dans la liste des étudiants
etu = r.json()[randint(0, len(r.json())) - 1]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(etu, fields_long)
assert fields_OK is True
# etudiant
def test_etudiant(): # XXX TODO pour Seb
def test_etudiant():
fields = [
"civilite",
@ -167,12 +137,7 @@ def test_etudiant(): # XXX TODO pour Seb
etu = r.json()
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(etu, fields)
assert fields_OK is True
@ -188,12 +153,7 @@ def test_etudiant(): # XXX TODO pour Seb
etu = r.json()
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(etu, fields)
assert fields_OK is True
@ -209,18 +169,13 @@ def test_etudiant(): # XXX TODO pour Seb
etu = r.json()
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in etu:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(etu, fields)
assert fields_OK is True
# etudiant_formsemestres
def test_etudiant_formsemestres(): # XXX TODO pour Seb
def test_etudiant_formsemestres():
fields = [
"date_fin",
@ -262,12 +217,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
formsemestre = r.json()[0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(formsemestre, fields)
assert fields_OK is True
@ -283,12 +233,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
formsemestre = r.json()[0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(formsemestre, fields)
assert fields_OK is True
@ -304,12 +249,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
formsemestre = r.json()[0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(formsemestre, fields)
assert fields_OK is True
@ -317,24 +257,6 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
# etudiant_bulletin_semestre
def test_etudiant_bulletin_semestre():
# fields = [
# "etudid",
# "formsemestre_id",
# "date",
# "publie",
# "etapes",
# "etudiant",
# "note",
# "rang",
# "rang_group",
# "note_max",
# "bonus_sport_culture",
# "ue",
# "ue_capitalisee",
# "absences",
# "appreciation",
# ]
######### Test etudid #########
r = requests.get(
@ -345,17 +267,6 @@ def test_etudiant_bulletin_semestre():
assert r.status_code == 200
assert len(r.json()) == 13
# bulletin = r.json()
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in bulletin:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
######### Test code nip #########
r = requests.get(
@ -366,17 +277,6 @@ def test_etudiant_bulletin_semestre():
assert r.status_code == 200
assert len(r.json()) == 13
# bulletin = r.json()
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in bulletin:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
######### Test code ine #########
r = requests.get(
@ -387,17 +287,6 @@ def test_etudiant_bulletin_semestre():
assert r.status_code == 200
assert len(r.json()) == 13
# bulletin = r.json()
#
# fields_OK = True
#
# # Vérifie si tous les champs sont bien présents
# for field in bulletin:
# if field not in fields:
# fields_OK = False
#
# assert fields_OK is True
# etudiant_groups
def test_etudiant_groups():
@ -426,12 +315,7 @@ def test_etudiant_groups():
groups = r.json()[0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in groups:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(groups, fields)
assert fields_OK is True
@ -447,12 +331,7 @@ def test_etudiant_groups():
groups = r.json()[0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in groups:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(groups, fields)
assert fields_OK is True
@ -468,11 +347,6 @@ def test_etudiant_groups():
groups = r.json()[0]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in groups:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(groups, fields)
assert fields_OK is True

View File

@ -20,63 +20,162 @@ Utilisation :
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# formations
def test_formations():
fields = [
"id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
formation = r.json()[0]
fields_OK = verify_fields(formation, fields)
assert r.status_code == 200
assert len(r.json()) == 1
assert fields_OK is True
# formations_by_id
def test_formations_by_id():
fields = [
"id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
formation = r.json()
fields_OK = verify_fields(formation, fields)
assert r.status_code == 200
assert fields_OK is True
# formation_export_by_formation_id
def test_formation_export_by_formation_id():
fields = [
"id",
"acronyme",
"titre_officiel",
"formation_code",
"code_specialite",
"dept_id",
"titre",
"version",
"type_parcours",
"referentiel_competence_id",
"formation_id",
"ue",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/formation_export/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
export_formation = r.json()
fields_OK = verify_fields(export_formation, fields)
assert r.status_code == 200
assert fields_OK is True
# formsemestre_apo
def test_formsemestre_apo():
# def test_formsemestre_apo():
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/formations/apo/<string:etape_apo>",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# moduleimpl
def test_moduleimpl():
fields = [
"id",
"formsemestre_id",
"computation_expr",
"module_id",
"responsable_id",
"moduleimpl_id",
"ens",
"module",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/apo/<string:etape_apo>",
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
moduleimpl = r.json()
fields_OK = verify_fields(moduleimpl, fields)
# moduleimpls
def test_moduleimpls():
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/<int:moduleimpl_id>",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert fields_OK is True
# moduleimpls_sem
def test_moduleimpls_sem():
fields = [
"id",
"formsemestre_id",
"computation_expr",
"module_id",
"responsable_id",
"moduleimpl_id",
"ens",
"module",
"moduleimpl_id",
"ens",
]
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
moduleimpl = r.json()[0]
fields_OK = verify_fields(moduleimpl, fields)
assert r.status_code == 200
assert len(r.json()) == 21
assert fields_OK is True

View File

@ -20,6 +20,7 @@ Utilisation :
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# formsemestre
def test_formsemestre():
@ -60,37 +61,29 @@ def test_formsemestre():
"responsables",
]
fields_OK = True
# Vérifie si tous les champs sont bien présents
for field in formsemestre:
if field not in fields:
fields_OK = False
fields_OK = verify_fields(formsemestre, fields)
assert fields_OK is True
# etudiant_bulletin
def test_etudiant_bulletin(): #XXX TODO pour Seb
def test_etudiant_bulletin():
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/etudid/1/bulletin",
SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/etudid/1/bulletin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/nip/1/bulletin",
SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/nip/1/bulletin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/ine/1/bulletin",
SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/ine/1/bulletin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
@ -115,3 +108,83 @@ def test_bulletins():
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# semestre_index
def test_semestre_index():
ue_fields = [
"semestre_idx",
"type",
"formation_id",
"ue_code",
"id",
"ects",
"acronyme",
"is_external",
"numero",
"code_apogee",
"titre",
"coefficient",
"color",
"ue_id",
]
ressource_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
sae_fields = [
"heures_tp",
"code_apogee",
"titre",
"coefficient",
"module_type",
"id",
"ects",
"abbrev",
"ue_id",
"code",
"formation_id",
"heures_cours",
"matiere_id",
"heures_td",
"semestre_id",
"numero",
"module_id",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/1/programme",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 3
ue = r.json()["ues"][0]
ressource = r.json()["ressources"][0]
sae = r.json()["saes"][0]
fields_ue_OK = verify_fields(ue, ue_fields)
fields_ressource_OK = verify_fields(ressource, ressource_fields)
fields_sae_OK = verify_fields(sae, sae_fields)
assert fields_ue_OK is True
assert fields_ressource_OK is True
assert fields_sae_OK is True

View File

@ -20,40 +20,105 @@ Utilisation :
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# partition
def test_partition():
fields = [
"partition_id",
"id",
"formsemestre_id",
"partition_name",
"numero",
"bul_show_rank",
"show_in_lists",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/partitions/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
partition = r.json()[0]
fields_OK = verify_fields(partition, fields)
assert r.status_code == 200
assert len(r.json()) == 2
assert fields_OK is True
# etud_in_group
def test_etud_in_group():
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",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/partitions/groups/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
etu = r.json()[0]
fields_OK = verify_fields(etu, fields)
assert r.status_code == 200
r = requests.get(
SCODOC_URL + "/ScoDoc/api/partitions/groups/<int:group_id>/etat/<string:etat>",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
assert len(r.json()) == 16
assert fields_OK is True
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/partitions/groups/1/etat/<string:etat>",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200
# set_groups
def test_set_groups():
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/partitions/set_groups?partition_id=<int:partition_id>&groups_lists=<int:groups_lists>&"
"groups_to_create=<int:groups_to_create>&groups_to_delete=<int:groups_to_delete>",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# # set_groups
# def test_set_groups():
# r = requests.get(
# SCODOC_URL
# + "/partitions/set_groups/partition/<int:partition_id>/groups/<string:groups_id>"
# "/delete/<string:groups_to_delete>/create/<string:groups_to_create>",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200

View File

@ -0,0 +1,13 @@
def verify_fields(json_response, fields):
"""
Vérifie si les champs de la réponse json sont corrects
json_response : la réponse de la requête
fields : une liste avec l'ensemble des champs à vérifier
Retourne True ou False
"""
for field in json_response:
if field not in fields:
return False
return True