From aba6330065c1691c2cbcd057175648f3ba36bad9 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Thu, 28 Apr 2022 16:12:15 +0200 Subject: [PATCH 1/4] ajout des tests pour la version 'long' de etudiant_courant + correction routes et doc sur les fichiers api --- app/api/absences.py | 8 +- app/api/etudiants.py | 2 +- app/api/evaluations.py | 42 +++++------ app/api/formations.py | 10 +-- app/api/formsemestres.py | 29 ++++++++ app/api/partitions.py | 6 +- tests/api/test_api_etudiants.py | 128 ++++++++++++++------------------ 7 files changed, 119 insertions(+), 106 deletions(-) diff --git a/app/api/absences.py b/app/api/absences.py index 35abe34ff1..35056a05b3 100644 --- a/app/api/absences.py +++ b/app/api/absences.py @@ -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=&date_debut=date_debut&date_fin=date_fin", + "/absences/abs_group_etat/", + methods=["GET"], +) +@bp.route( + "/absences/abs_group_etat/group_id//date_debut//date_fin/", methods=["GET"], ) @token_permission_required(Permission.APIView) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 1f22463ec4..4cab02a090 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -59,7 +59,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) diff --git a/app/api/evaluations.py b/app/api/evaluations.py index 2f6049d999..4cbfa9f33c 100644 --- a/app/api/evaluations.py +++ b/app/api/evaluations.py @@ -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() diff --git a/app/api/formations.py b/app/api/formations.py index f7d1a64247..ee017514d5 100644 --- a/app/api/formations.py +++ b/app/api/formations.py @@ -177,7 +177,7 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): 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, @@ -192,15 +192,15 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): @token_permission_required(Permission.APIView) def moduleimpls(moduleimpl_id: int): """ - Retourne la liste des moduleimpl + Retourne un module moduleimpl en fonction de son id moduleimpl_id : l'id d'un moduleimpl """ # 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 +208,7 @@ def moduleimpls(moduleimpl_id: int): @bp.route( "/formations/moduleimpl/formsemestre//liste", methods=["GET"], -) # XXX TODO penser à changer la route sur la doc +) @token_permission_required(Permission.APIView) def moduleimpls_sem(formsemestre_id: int): """ diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 9704d753c7..4ab86132e0 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -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, diff --git a/app/api/partitions.py b/app/api/partitions.py index 2af2f7cf78..d925d17496 100644 --- a/app/api/partitions.py +++ b/app/api/partitions.py @@ -121,13 +121,13 @@ def etud_in_group(group_id: int, etat=None): @bp.route( - "/partitions/set_groups?partition_id=&groups_lists=&" - "groups_to_create=&groups_to_delete=", + "/partitions/set_groups/partition//groups//delete/" + "/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 diff --git a/tests/api/test_api_etudiants.py b/tests/api/test_api_etudiants.py index e568a4f9b0..6ebecbc7af 100644 --- a/tests/api/test_api_etudiants.py +++ b/tests/api/test_api_etudiants.py @@ -23,85 +23,16 @@ import requests from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS -# # etudiants -# def test_etudiants(): -# -# fields = [ -# "civilite", -# "code_ine", -# "code_nip", -# "date_naissance", -# "email", -# "emailperso", -# "etudid", -# "nom", -# "prenom", -# "nomprenom", -# "lieu_naissance", -# "dept_naissance", -# "nationalite", -# "boursier", -# "id", -# "domicile", -# "villedomicile", -# "telephone", -# "fax", -# "description", -# "codepostaldomicile", -# "paysdomicile", -# "telephonemobile", -# "typeadresse", -# ] -# -# r = requests.get( -# SCODOC_URL + "/ScoDoc/api/etudiants", -# headers=HEADERS, -# verify=CHECK_CERTIFICATE, -# ) -# assert r.status_code == 200 -# assert len(r.json()) == 16 -# -# # Choisis aléatoirement un étudiant dans la liste des étudiants -# etu = r.json()[randint(0, len(r.json())) - 1] -# -# fields_OK = True -# -# # Vérifie si tous les champs sont bien présents -# for field in etu: -# if field not in fields: -# fields_OK = False -# -# assert fields_OK is True - - # etudiants_courant def test_etudiants_courant(): # XXX TODO pour Seb 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", + "nip", + "nom", + "nom_usuel", + "prenom", + "civilite", ] r = requests.get( @@ -124,6 +55,55 @@ def test_etudiants_courant(): # XXX TODO pour Seb assert fields_OK is True + ########## Version long################ + + fields_long = [ + "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/etudiants/courant/long", + 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_long: + fields_OK = False + + assert fields_OK is True + # etudiant def test_etudiant(): # XXX TODO pour Seb From bac99da7263f79d0ff6ed4afe4677354d7eb3ac6 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Mon, 2 May 2022 09:38:41 +0200 Subject: [PATCH 2/4] fixe du format de retour de etudiant_formsemestre et formsemestre --- app/api/etudiants.py | 58 ++++++++-------- app/api/formsemestres.py | 142 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 159 insertions(+), 41 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 4cab02a090..9f40cf6b5e 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -111,36 +111,34 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None) 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 diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 4ab86132e0..e4a0a94317 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -107,21 +107,21 @@ def formsemestre_apo(etape_apo: str): @bp.route( - "/formsemestre//departements//etudiant/etudid//bulletin", - methods=["GET"], -) -@bp.route( - "/formsemestre//departements//etudiant/nip//bulletin", - methods=["GET"], -) -@bp.route( - "/formsemestre//departements//etudiant/ine//bulletin", + "/formsemestre//etudiant/etudid//bulletin", methods=["GET"], ) +# @bp.route( +# "/formsemestre//departements//etudiant/nip//bulletin", +# methods=["GET"], +# ) +# @bp.route( +# "/formsemestre//departements//etudiant/ine//bulletin", +# methods=["GET"], +# ) @token_permission_required(Permission.APIView) def etudiant_bulletin( formsemestre_id, - dept, + # dept, etudid: int = None, nip: int = None, ine: int = None, @@ -241,7 +241,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, @@ -499,3 +507,115 @@ def jury(formsemestre_id: int): # ) return jsonify(data) + + +@bp.route( + "/formsemestre//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 From a7cb96a9fc8980c4ef3ea7304569d14319963a17 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Mon, 2 May 2022 16:29:26 +0200 Subject: [PATCH 3/4] Ajustement sur formsemestre.py et departement.py + renforcement et factorisation des tests departement, etudiant et formsemestre --- app/api/departements.py | 114 ---------------- app/api/formsemestres.py | 17 ++- tests/api/test_api_departements.py | 201 ++++++++++++++--------------- tests/api/test_api_etudiants.py | 137 +++----------------- tests/api/test_api_formations.py | 3 +- tests/api/test_api_formsemestre.py | 101 +++++++++++++-- tests/api/tools_test_api.py | 13 ++ 7 files changed, 226 insertions(+), 360 deletions(-) create mode 100644 tests/api/tools_test_api.py diff --git a/app/api/departements.py b/app/api/departements.py index 924d1e441a..482bceca63 100644 --- a/app/api/departements.py +++ b/app/api/departements.py @@ -187,117 +187,3 @@ def referenciel_competences(dept: str, formation_id: int): ) else: return jsonify(ref_comp) - - -@bp.route( - "/departements//formsemestre//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 diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index e4a0a94317..122abf148c 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -110,18 +110,17 @@ def formsemestre_apo(etape_apo: str): "/formsemestre//etudiant/etudid//bulletin", methods=["GET"], ) -# @bp.route( -# "/formsemestre//departements//etudiant/nip//bulletin", -# methods=["GET"], -# ) -# @bp.route( -# "/formsemestre//departements//etudiant/ine//bulletin", -# methods=["GET"], -# ) +@bp.route( + "/formsemestre//etudiant/nip//bulletin", + methods=["GET"], +) +@bp.route( + "/formsemestre//etudiant/ine//bulletin", + methods=["GET"], +) @token_permission_required(Permission.APIView) def etudiant_bulletin( formsemestre_id, - # dept, etudid: int = None, nip: int = None, ine: int = None, diff --git a/tests/api/test_api_departements.py b/tests/api/test_api_departements.py index 9e04e8d547..e0b82f2306 100644 --- a/tests/api/test_api_departements.py +++ b/tests/api/test_api_departements.py @@ -21,9 +21,18 @@ 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 +41,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 diff --git a/tests/api/test_api_etudiants.py b/tests/api/test_api_etudiants.py index 6ebecbc7af..da40dfc5cd 100644 --- a/tests/api/test_api_etudiants.py +++ b/tests/api/test_api_etudiants.py @@ -24,7 +24,10 @@ from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS # etudiants_courant -def test_etudiants_courant(): # XXX TODO pour Seb +from tests.api.tools_test_api import verify_fields + + +def test_etudiants_courant(): fields = [ "id", @@ -46,12 +49,7 @@ 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) assert fields_OK is True @@ -95,18 +93,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_long: - 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", @@ -147,12 +140,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 @@ -168,12 +156,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 @@ -189,18 +172,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", @@ -242,12 +220,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 @@ -263,12 +236,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 @@ -284,12 +252,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 @@ -297,24 +260,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( @@ -325,17 +270,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( @@ -346,17 +280,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( @@ -367,17 +290,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(): @@ -406,12 +318,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 @@ -427,12 +334,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 @@ -448,11 +350,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 diff --git a/tests/api/test_api_formations.py b/tests/api/test_api_formations.py index 983ab3825a..aaaa52831b 100644 --- a/tests/api/test_api_formations.py +++ b/tests/api/test_api_formations.py @@ -74,8 +74,7 @@ def test_moduleimpls(): # moduleimpls_sem def test_moduleimpls_sem(): 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, ) diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py index a16d751ae5..044fa856bb 100644 --- a/tests/api/test_api_formsemestre.py +++ b/tests/api/test_api_formsemestre.py @@ -22,6 +22,9 @@ import requests from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS # formsemestre +from tests.api.tools_test_api import verify_fields + + def test_formsemestre(): r = requests.get( SCODOC_URL + "/ScoDoc/api/formsemestre/1", @@ -60,37 +63,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 +110,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 diff --git a/tests/api/tools_test_api.py b/tests/api/tools_test_api.py new file mode 100644 index 0000000000..4501cd3ccc --- /dev/null +++ b/tests/api/tools_test_api.py @@ -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 From e74d075bda05bbf920b2d53edcf4e611bbe50f8f Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Tue, 3 May 2022 16:15:04 +0200 Subject: [PATCH 4/4] Tests unitaires pour les parties formations et partitions + correction d'exemples de resultats --- app/api/etudiants.py | 135 +++++++++++++++-------------- app/api/formations.py | 34 +++++++- tests/api/test_api_departements.py | 1 - tests/api/test_api_etudiants.py | 5 +- tests/api/test_api_formations.py | 120 ++++++++++++++++++++++--- tests/api/test_api_formsemestre.py | 4 +- tests/api/test_api_partitions.py | 97 +++++++++++++++++---- 7 files changed, 295 insertions(+), 101 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 9f40cf6b5e..c04495abe9 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -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( @@ -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,36 +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 : - [ - { - "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": [] - }, - ... - ] + [ + { + "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) diff --git a/app/api/formations.py b/app/api/formations.py index ee017514d5..920d9af4c4 100644 --- a/app/api/formations.py +++ b/app/api/formations.py @@ -32,7 +32,6 @@ def formations(): }, ... ] - """ # Récupération de toutes les formations list_formations = models.Formation.query.all() @@ -171,7 +170,6 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): }, ] } - """ # Fonction utilité : app.scodoc.sco_formations.formation_export() @@ -190,11 +188,41 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): @bp.route("/formations/moduleimpl/", methods=["GET"]) @token_permission_required(Permission.APIView) -def moduleimpls(moduleimpl_id: int): +def moduleimpl(moduleimpl_id: int): """ 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 moduleimpl = models.ModuleImpl.query.filter_by(id=moduleimpl_id).first_or_404() diff --git a/tests/api/test_api_departements.py b/tests/api/test_api_departements.py index e0b82f2306..b9f762b90e 100644 --- a/tests/api/test_api_departements.py +++ b/tests/api/test_api_departements.py @@ -20,7 +20,6 @@ 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 diff --git a/tests/api/test_api_etudiants.py b/tests/api/test_api_etudiants.py index da40dfc5cd..c0314a1e66 100644 --- a/tests/api/test_api_etudiants.py +++ b/tests/api/test_api_etudiants.py @@ -21,12 +21,9 @@ from random import randint import requests from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS - - -# etudiants_courant from tests.api.tools_test_api import verify_fields - +# etudiants_courant def test_etudiants_courant(): fields = [ diff --git a/tests/api/test_api_formations.py b/tests/api/test_api_formations.py index aaaa52831b..346e333e0c 100644 --- a/tests/api/test_api_formations.py +++ b/tests/api/test_api_formations.py @@ -20,62 +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/", +# 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/", + 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/", - 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", 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 diff --git a/tests/api/test_api_formsemestre.py b/tests/api/test_api_formsemestre.py index 044fa856bb..ac84cbafd6 100644 --- a/tests/api/test_api_formsemestre.py +++ b/tests/api/test_api_formsemestre.py @@ -20,11 +20,9 @@ Utilisation : import requests from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS - -# formsemestre from tests.api.tools_test_api import verify_fields - +# formsemestre def test_formsemestre(): r = requests.get( SCODOC_URL + "/ScoDoc/api/formsemestre/1", diff --git a/tests/api/test_api_partitions.py b/tests/api/test_api_partitions.py index 51719aa62c..f7af82b0a8 100644 --- a/tests/api/test_api_partitions.py +++ b/tests/api/test_api_partitions.py @@ -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//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/", + # 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=&groups_lists=&" - "groups_to_create=&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//groups/" +# "/delete//create/", +# headers=HEADERS, +# verify=CHECK_CERTIFICATE, +# ) +# assert r.status_code == 200