Tests unitaires pour les parties formations et partitions + correction d'exemples de resultats

This commit is contained in:
leonard_montalbano 2022-05-03 16:15:04 +02:00
parent a7cb96a9fc
commit e74d075bda
7 changed files with 295 additions and 101 deletions

View File

@ -22,31 +22,23 @@ def etudiants_courant(long=False):
Retourne la liste des étudiants courant Retourne la liste des étudiants courant
Exemple de résultat : Exemple de résultat :
{ [
{ {
"civilite": "X", "id": 1,
"code_ine": null, "nip": 1,
"code_nip": null,
"date_naissance": null,
"email": null,
"emailperso": null,
"etudid": 18,
"nom": "MOREL", "nom": "MOREL",
"prenom": "JACQUES" "prenom": "JACQUES",
},
{
"civilite": "X", "civilite": "X",
"code_ine": null, },
"code_nip": null, {
"date_naissance": null, "id": 2,
"email": null, "nip": 2,
"emailperso": null, "nom": "GILLES",
"etudid": 19, "prenom": "MAXIME",
"nom": "FOURNIER", "civilite": "X",
"prenom": "ANNE" },
}, ...
... ]
}
""" """
# Récupération de tous les étudiants # Récupération de tous les étudiants
etuds = Identite.query.filter( 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 ine : le code ine d'un étudiant
Exemple de résultat : Exemple de résultat :
{ {
"civilite": "X", "civilite": "X",
"code_ine": null, "code_ine": "1",
"code_nip": null, "code_nip": "1",
"date_naissance": null, "date_naissance": "",
"email": null, "email": "SACHA.COSTA@example.com",
"emailperso": null, "emailperso": "",
"etudid": 18, "etudid": 1,
"nom": "MOREL", "nom": "COSTA",
"prenom": "JACQUES" "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 # Récupération de l'étudiant
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine) 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 ine : le code ine d'un étudiant
Exemple de résultat : Exemple de résultat :
[ [
{ {
"date_fin": "31/08/2022", "date_fin": "31/08/2022",
"resp_can_edit": false, "resp_can_edit": false,
"dept_id": 1, "dept_id": 1,
"etat": true, "etat": true,
"resp_can_change_ens": true, "resp_can_change_ens": true,
"id": 1, "id": 1,
"modalite": "FI", "modalite": "FI",
"ens_can_edit_eval": false, "ens_can_edit_eval": false,
"formation_id": 1, "formation_id": 1,
"gestion_compensation": false, "gestion_compensation": false,
"elt_sem_apo": null, "elt_sem_apo": null,
"semestre_id": 1, "semestre_id": 1,
"bul_hide_xml": false, "bul_hide_xml": false,
"elt_annee_apo": null, "elt_annee_apo": null,
"titre": "Semestre test", "titre": "Semestre test",
"block_moyennes": false, "block_moyennes": false,
"scodoc7_id": null, "scodoc7_id": null,
"date_debut": "01/09/2021", "date_debut": "01/09/2021",
"gestion_semestrielle": false, "gestion_semestrielle": false,
"bul_bgcolor": "white", "bul_bgcolor": "white",
"formsemestre_id": 1, "formsemestre_id": 1,
"titre_num": "Semestre test semestre 1", "titre_num": "Semestre test semestre 1",
"date_debut_iso": "2021-09-01", "date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-08-31", "date_fin_iso": "2022-08-31",
"responsables": [] "responsables": []
}, },
... ...
] ]
""" """
# Récupération de l'étudiant # Récupération de l'étudiant
etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine) etud = get_etu_from_etudid_or_nip_or_ine(etudid, nip, ine)

View File

@ -32,7 +32,6 @@ def formations():
}, },
... ...
] ]
""" """
# Récupération de toutes les formations # Récupération de toutes les formations
list_formations = models.Formation.query.all() 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() # 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/<int:moduleimpl_id>", methods=["GET"]) @bp.route("/formations/moduleimpl/<int:moduleimpl_id>", methods=["GET"])
@token_permission_required(Permission.APIView) @token_permission_required(Permission.APIView)
def moduleimpls(moduleimpl_id: int): def moduleimpl(moduleimpl_id: int):
""" """
Retourne un module moduleimpl en fonction de son id Retourne un module moduleimpl en fonction de son id
moduleimpl_id : l'id d'un moduleimpl 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 # Récupération des tous les moduleimpl
moduleimpl = models.ModuleImpl.query.filter_by(id=moduleimpl_id).first_or_404() moduleimpl = models.ModuleImpl.query.filter_by(id=moduleimpl_id).first_or_404()

View File

@ -20,7 +20,6 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields from tests.api.tools_test_api import verify_fields
# departements # departements

View File

@ -21,12 +21,9 @@ from random import randint
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# etudiants_courant
from tests.api.tools_test_api import verify_fields from tests.api.tools_test_api import verify_fields
# etudiants_courant
def test_etudiants_courant(): def test_etudiants_courant():
fields = [ fields = [

View File

@ -20,62 +20,162 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# formations # formations
def test_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( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations", SCODOC_URL + "/ScoDoc/api/formations",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
formation = r.json()[0]
fields_OK = verify_fields(formation, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 1
assert fields_OK is True
# formations_by_id # formations_by_id
def test_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( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/1", SCODOC_URL + "/ScoDoc/api/formations/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
formation = r.json()
fields_OK = verify_fields(formation, fields)
assert r.status_code == 200 assert r.status_code == 200
assert fields_OK is True
# formation_export_by_formation_id # formation_export_by_formation_id
def test_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( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/formation_export/1", SCODOC_URL + "/ScoDoc/api/formations/formation_export/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
export_formation = r.json()
fields_OK = verify_fields(export_formation, fields)
assert r.status_code == 200 assert r.status_code == 200
assert fields_OK is True
# formsemestre_apo # 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( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/apo/<string:etape_apo>", SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/1",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, 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 r.status_code == 200
assert fields_OK is True
# moduleimpls_sem # moduleimpls_sem
def test_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( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste", SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
headers=HEADERS, headers=HEADERS,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
moduleimpl = r.json()[0]
fields_OK = verify_fields(moduleimpl, fields)
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 21
assert fields_OK is True

View File

@ -20,11 +20,9 @@ Utilisation :
import requests import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
# formsemestre
from tests.api.tools_test_api import verify_fields from tests.api.tools_test_api import verify_fields
# formsemestre
def test_formsemestre(): def test_formsemestre():
r = requests.get( r = requests.get(
SCODOC_URL + "/ScoDoc/api/formsemestre/1", SCODOC_URL + "/ScoDoc/api/formsemestre/1",

View File

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