forked from ScoDoc/ScoDoc
Ajustement sur formsemestre.py et departement.py + renforcement et factorisation des tests departement, etudiant et formsemestre
This commit is contained in:
parent
ffd0782f8a
commit
a7cb96a9fc
@ -187,117 +187,3 @@ def referenciel_competences(dept: str, formation_id: int):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return jsonify(ref_comp)
|
return jsonify(ref_comp)
|
||||||
|
|
||||||
|
|
||||||
@bp.route(
|
|
||||||
"/departements/<string:dept>/formsemestre/<string:formsemestre_id>/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
|
|
||||||
|
@ -110,18 +110,17 @@ def formsemestre_apo(etape_apo: str):
|
|||||||
"/formsemestre/<int:formsemestre_id>/etudiant/etudid/<int:etudid>/bulletin",
|
"/formsemestre/<int:formsemestre_id>/etudiant/etudid/<int:etudid>/bulletin",
|
||||||
methods=["GET"],
|
methods=["GET"],
|
||||||
)
|
)
|
||||||
# @bp.route(
|
@bp.route(
|
||||||
# "/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/nip/<int:nip>/bulletin",
|
"/formsemestre/<int:formsemestre_id>/etudiant/nip/<int:nip>/bulletin",
|
||||||
# methods=["GET"],
|
methods=["GET"],
|
||||||
# )
|
)
|
||||||
# @bp.route(
|
@bp.route(
|
||||||
# "/formsemestre/<int:formsemestre_id>/departements/<string:dept>/etudiant/ine/<int:ine>/bulletin",
|
"/formsemestre/<int:formsemestre_id>/etudiant/ine/<int:ine>/bulletin",
|
||||||
# methods=["GET"],
|
methods=["GET"],
|
||||||
# )
|
)
|
||||||
@token_permission_required(Permission.APIView)
|
@token_permission_required(Permission.APIView)
|
||||||
def etudiant_bulletin(
|
def etudiant_bulletin(
|
||||||
formsemestre_id,
|
formsemestre_id,
|
||||||
# dept,
|
|
||||||
etudid: int = None,
|
etudid: int = None,
|
||||||
nip: int = None,
|
nip: int = None,
|
||||||
ine: int = None,
|
ine: int = None,
|
||||||
|
@ -21,9 +21,18 @@ 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
|
||||||
|
|
||||||
# departements
|
# departements
|
||||||
def test_departements(): #XXX TODO pour Seb
|
def test_departements():
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"acronym",
|
||||||
|
"description",
|
||||||
|
"visible",
|
||||||
|
"date_creation",
|
||||||
|
]
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/departements",
|
SCODOC_URL + "/ScoDoc/api/departements",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
@ -32,134 +41,122 @@ def test_departements(): #XXX TODO pour Seb
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 1
|
assert len(r.json()) == 1
|
||||||
|
|
||||||
|
dept = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(dept, fields)
|
||||||
|
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# liste_etudiants
|
# 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(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste",
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste",
|
||||||
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
|
||||||
assert len(r.json()) == 16
|
assert len(r.json()) == 16
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/1",
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/etudiants/liste/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
|
||||||
assert len(r.json()) == 16
|
assert len(r.json()) == 16
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# liste_semestres_courant
|
# 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(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
|
SCODOC_URL + "/ScoDoc/api/departements/TAPI/semestres_courants",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sem = r.json()[0]
|
||||||
|
|
||||||
|
fields_OK = verify_fields(sem, fields)
|
||||||
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 1
|
assert len(r.json()) == 1
|
||||||
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# referenciel_competences
|
# referenciel_competences
|
||||||
def test_referenciel_competences():
|
def test_referenciel_competences():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL
|
SCODOC_URL
|
||||||
+ "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences",
|
+ "/ScoDoc/api/departements/TAPI/formations/1/referentiel_competences",
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200 or 204
|
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
|
|
||||||
|
@ -24,7 +24,10 @@ from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
|
|||||||
|
|
||||||
|
|
||||||
# etudiants_courant
|
# etudiants_courant
|
||||||
def test_etudiants_courant(): # XXX TODO pour Seb
|
from tests.api.tools_test_api import verify_fields
|
||||||
|
|
||||||
|
|
||||||
|
def test_etudiants_courant():
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"id",
|
"id",
|
||||||
@ -46,12 +49,7 @@ def test_etudiants_courant(): # XXX TODO pour Seb
|
|||||||
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
||||||
etu = r.json()[randint(0, len(r.json())) - 1]
|
etu = r.json()[randint(0, len(r.json())) - 1]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(etu, fields)
|
||||||
|
|
||||||
# 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
|
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
|
# Choisis aléatoirement un étudiant dans la liste des étudiants
|
||||||
etu = r.json()[randint(0, len(r.json())) - 1]
|
etu = r.json()[randint(0, len(r.json())) - 1]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(etu, fields_long)
|
||||||
|
|
||||||
# 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
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# etudiant
|
# etudiant
|
||||||
def test_etudiant(): # XXX TODO pour Seb
|
def test_etudiant():
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"civilite",
|
"civilite",
|
||||||
@ -147,12 +140,7 @@ def test_etudiant(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
etu = r.json()
|
etu = r.json()
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(etu, fields)
|
||||||
|
|
||||||
# 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
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -168,12 +156,7 @@ def test_etudiant(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
etu = r.json()
|
etu = r.json()
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(etu, fields)
|
||||||
|
|
||||||
# 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
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -189,18 +172,13 @@ def test_etudiant(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
etu = r.json()
|
etu = r.json()
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(etu, fields)
|
||||||
|
|
||||||
# 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
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# etudiant_formsemestres
|
# etudiant_formsemestres
|
||||||
def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
def test_etudiant_formsemestres():
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"date_fin",
|
"date_fin",
|
||||||
@ -242,12 +220,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
formsemestre = r.json()[0]
|
formsemestre = r.json()[0]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(formsemestre, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in formsemestre:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -263,12 +236,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
formsemestre = r.json()[0]
|
formsemestre = r.json()[0]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(formsemestre, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in formsemestre:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -284,12 +252,7 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
|
|
||||||
formsemestre = r.json()[0]
|
formsemestre = r.json()[0]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(formsemestre, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in formsemestre:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -297,24 +260,6 @@ def test_etudiant_formsemestres(): # XXX TODO pour Seb
|
|||||||
# etudiant_bulletin_semestre
|
# etudiant_bulletin_semestre
|
||||||
def test_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 #########
|
######### Test etudid #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
@ -325,17 +270,6 @@ def test_etudiant_bulletin_semestre():
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 13
|
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 #########
|
######### Test code nip #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
@ -346,17 +280,6 @@ def test_etudiant_bulletin_semestre():
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 13
|
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 #########
|
######### Test code ine #########
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
@ -367,17 +290,6 @@ def test_etudiant_bulletin_semestre():
|
|||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.json()) == 13
|
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
|
# etudiant_groups
|
||||||
def test_etudiant_groups():
|
def test_etudiant_groups():
|
||||||
@ -406,12 +318,7 @@ def test_etudiant_groups():
|
|||||||
|
|
||||||
groups = r.json()[0]
|
groups = r.json()[0]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(groups, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in groups:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -427,12 +334,7 @@ def test_etudiant_groups():
|
|||||||
|
|
||||||
groups = r.json()[0]
|
groups = r.json()[0]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(groups, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in groups:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
@ -448,11 +350,6 @@ def test_etudiant_groups():
|
|||||||
|
|
||||||
groups = r.json()[0]
|
groups = r.json()[0]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(groups, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in groups:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
@ -74,8 +74,7 @@ def test_moduleimpls():
|
|||||||
# moduleimpls_sem
|
# moduleimpls_sem
|
||||||
def test_moduleimpls_sem():
|
def test_moduleimpls_sem():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL
|
SCODOC_URL + "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
|
||||||
+ "/ScoDoc/api/formations/moduleimpl/formsemestre/1/liste",
|
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
|
@ -22,6 +22,9 @@ 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
|
# formsemestre
|
||||||
|
from tests.api.tools_test_api import verify_fields
|
||||||
|
|
||||||
|
|
||||||
def test_formsemestre():
|
def test_formsemestre():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL + "/ScoDoc/api/formsemestre/1",
|
SCODOC_URL + "/ScoDoc/api/formsemestre/1",
|
||||||
@ -60,37 +63,29 @@ def test_formsemestre():
|
|||||||
"responsables",
|
"responsables",
|
||||||
]
|
]
|
||||||
|
|
||||||
fields_OK = True
|
fields_OK = verify_fields(formsemestre, fields)
|
||||||
|
|
||||||
# Vérifie si tous les champs sont bien présents
|
|
||||||
for field in formsemestre:
|
|
||||||
if field not in fields:
|
|
||||||
fields_OK = False
|
|
||||||
|
|
||||||
assert fields_OK is True
|
assert fields_OK is True
|
||||||
|
|
||||||
|
|
||||||
# etudiant_bulletin
|
# etudiant_bulletin
|
||||||
def test_etudiant_bulletin(): #XXX TODO pour Seb
|
def test_etudiant_bulletin():
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL
|
SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/etudid/1/bulletin",
|
||||||
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/etudid/1/bulletin",
|
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL
|
SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/nip/1/bulletin",
|
||||||
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/nip/1/bulletin",
|
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
SCODOC_URL
|
SCODOC_URL + "/ScoDoc/api/formsemestre/1/etudiant/ine/1/bulletin",
|
||||||
+ "/ScoDoc/api/formsemestre/1/departements/TAPI/etudiant/ine/1/bulletin",
|
|
||||||
headers=HEADERS,
|
headers=HEADERS,
|
||||||
verify=CHECK_CERTIFICATE,
|
verify=CHECK_CERTIFICATE,
|
||||||
)
|
)
|
||||||
@ -115,3 +110,83 @@ def test_bulletins():
|
|||||||
# verify=CHECK_CERTIFICATE,
|
# verify=CHECK_CERTIFICATE,
|
||||||
# )
|
# )
|
||||||
# assert r.status_code == 200
|
# 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
|
||||||
|
13
tests/api/tools_test_api.py
Normal file
13
tests/api/tools_test_api.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user