160 lines
2.8 KiB
Python
160 lines
2.8 KiB
Python
"""Utilitaires pour les tests de l'API
|
|
"""
|
|
import json
|
|
|
|
|
|
def verify_fields(json_response: dict, expected_fields: set) -> bool:
|
|
"""
|
|
Vérifie si les champs attendu de la réponse json sont présents
|
|
|
|
json_response : la réponse de la requête
|
|
expected_fields : ensemble des champs à vérifier
|
|
|
|
Retourne True ou False
|
|
"""
|
|
return all(field in json_response for field in expected_fields)
|
|
|
|
|
|
def verify_occurences_ids_etus(json_response):
|
|
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",
|
|
"code_ine",
|
|
"code_nip",
|
|
"codepostaldomicile",
|
|
"date_naissance",
|
|
"dept_naissance",
|
|
"description",
|
|
"domicile",
|
|
"email",
|
|
"emailperso",
|
|
"etudid",
|
|
"id",
|
|
"lieu_naissance",
|
|
"nationalite",
|
|
"nom",
|
|
"nomprenom",
|
|
"paysdomicile",
|
|
"prenom",
|
|
"telephone",
|
|
"telephonemobile",
|
|
"typeadresse",
|
|
"villedomicile",
|
|
}
|
|
|
|
FORMATION_FIELDS = {
|
|
"id",
|
|
"acronyme",
|
|
"titre_officiel",
|
|
"formation_code",
|
|
"code_specialite",
|
|
"dept_id",
|
|
"titre",
|
|
"version",
|
|
"type_parcours",
|
|
"referentiel_competence_id",
|
|
"formation_id",
|
|
}
|
|
|
|
FSEM_FIELDS = {
|
|
"block_moyennes",
|
|
"bul_bgcolor",
|
|
"bul_hide_xml",
|
|
"date_debut_iso",
|
|
"date_debut",
|
|
"date_fin_iso",
|
|
"date_fin",
|
|
"dept_id",
|
|
"elt_annee_apo",
|
|
"elt_sem_apo",
|
|
"ens_can_edit_eval",
|
|
"etat",
|
|
"formation_id",
|
|
"formsemestre_id",
|
|
"gestion_compensation",
|
|
"gestion_semestrielle",
|
|
"id",
|
|
"modalite",
|
|
"resp_can_change_ens",
|
|
"resp_can_edit",
|
|
"responsables",
|
|
"semestre_id",
|
|
"titre_formation",
|
|
"titre_num",
|
|
"titre",
|
|
}
|
|
|
|
MODIMPL_FIELDS = {
|
|
"id",
|
|
"formsemestre_id",
|
|
"computation_expr",
|
|
"module_id",
|
|
"responsable_id",
|
|
"moduleimpl_id",
|
|
"ens",
|
|
"module",
|
|
}
|
|
|
|
MODULE_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",
|
|
}
|
|
|
|
UE_FIELDS = {
|
|
"semestre_idx",
|
|
"type",
|
|
"formation_id",
|
|
"ue_code",
|
|
"id",
|
|
"ects",
|
|
"acronyme",
|
|
"is_external",
|
|
"numero",
|
|
"code_apogee",
|
|
"titre",
|
|
"coefficient",
|
|
"color",
|
|
"ue_id",
|
|
}
|