test département, étudiant fini

This commit is contained in:
leonard_montalbano 2022-04-21 15:57:02 +02:00
parent 29715a740f
commit 07123089e2
2 changed files with 126 additions and 17 deletions

View File

@ -1,5 +1,5 @@
############################################### Departements ########################################################## ############################################### Departements ##########################################################
from flask import g import app
from flask import jsonify from flask import jsonify
from app import models from app import models
@ -196,4 +196,31 @@ def semestre_index(dept: str, formsemestre_id: int):
Retourne la liste des Ues, ressources et SAE d'un semestre Retourne la liste des Ues, ressources et SAE d'un semestre
""" """
return error_response(501, message="not implemented") app.set_sco_dept(dept)
formsemestre = models.FormSemestre.query.filter_by(id=formsemestre_id).first()
ues = formsemestre.query_ues()
ues_dict = []
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
#return error_response(501, message="not implemented")

View File

@ -55,9 +55,9 @@ def test_liste_etudiants(): #XXX TODO pour Seb
# liste_semestres_courant # liste_semestres_courant
def test_semestres_courant(): #XXX TODO pour Seb def test_semestres_courant(): #XXX TODO pour Seb
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,
) )
assert r.status_code == 200 assert r.status_code == 200
assert len(r.json()) == 1 assert len(r.json()) == 1
@ -66,18 +66,100 @@ def test_semestres_courant(): #XXX TODO pour Seb
# 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 # semestre_index
# def test_semestre_index(): #XXX TODO pour Seb def test_semestre_index(): #XXX TODO pour Seb
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme", ue_fields = [
# headers=HEADERS, verify=CHECK_CERTIFICATE "semestre_idx",
# ) "type",
# assert r.status_code == 200 "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