1
0
forked from ScoDoc/ScoDoc

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
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)

View File

@ -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/<int:moduleimpl_id>", 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()

View File

@ -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

View File

@ -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 = [

View File

@ -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/<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",
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,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",

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