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 ##########################################################
from flask import g
import app
from flask import jsonify
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
"""
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

@ -74,10 +74,92 @@ def test_referenciel_competences():
assert r.status_code == 200 or 204
# # semestre_index
# def test_semestre_index(): #XXX TODO pour Seb
# r = requests.get(
# SCODOC_URL + "/ScoDoc/api/departements/TAPI/formsemestre/1/programme",
# headers=HEADERS, verify=CHECK_CERTIFICATE
# )
# assert r.status_code == 200
# 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