diff --git a/tests/api/test_api_etudiants.py b/tests/api/test_api_etudiants.py index 090a85451..1167a9d75 100644 --- a/tests/api/test_api_etudiants.py +++ b/tests/api/test_api_etudiants.py @@ -20,7 +20,37 @@ 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, verify_occurences_ids_etus +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 ETUD_FIELDS, FSEM_FIELDS @@ -278,8 +308,326 @@ def test_etudiant_bulletin_semestre(api_headers): verify=CHECK_CERTIFICATE, ) assert r.status_code == 200 - bul = r.json() - assert len(bul) == 13 # HARDCODED + 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 ######### diff --git a/tests/api/tools_test_api.py b/tests/api/tools_test_api.py index e2a36510a..a71a7604d 100644 --- a/tests/api/tools_test_api.py +++ b/tests/api/tools_test_api.py @@ -15,7 +15,14 @@ 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): +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] @@ -188,3 +195,240 @@ 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"}