Compare commits

...

2 Commits

Author SHA1 Message Date
leonard_montalbano
b5e4017315 ajout tests unitaire pour evaluations et absences 2022-05-04 16:30:13 +02:00
leonard_montalbano
09ff7f5d5d ajout du champs titre_court pour les retours de formsemestres 2022-05-04 16:28:34 +02:00
6 changed files with 136 additions and 48 deletions

View File

@ -117,34 +117,32 @@ def liste_semestres_courant(dept: str):
Exemple de résultat :
[
{
"titre": "master machine info",
"gestion_semestrielle": false,
"scodoc7_id": null,
"date_debut": "01/09/2021",
"bul_bgcolor": null,
"date_fin": "15/12/2022",
"resp_can_edit": false,
"dept_id": 1,
"etat": true,
"resp_can_change_ens": false,
"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,
"block_moyennes": false,
"formsemestre_id": 1,
"titre_num": "master machine info semestre 1",
"date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-12-15",
"responsables": [
3,
2
]
"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": []
"titre_court": BUT MMI
},
...
]
@ -156,7 +154,7 @@ def liste_semestres_courant(dept: str):
semestres = models.FormSemestre.query.filter_by(dept_id=dept.id, etat=True)
# Mise en forme des données
data = [d.to_dict() for d in semestres]
data = [d.to_dict_api() for d in semestres]
return jsonify(data)

View File

@ -144,6 +144,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
"date_debut_iso": "2021-09-01",
"date_fin_iso": "2022-08-31",
"responsables": []
"titre_court": BUT MMI
},
...
]
@ -156,7 +157,7 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
models.FormSemestreInscription.formsemestre_id == models.FormSemestre.id,
).order_by(models.FormSemestre.date_debut)
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres])
@bp.route(

View File

@ -56,7 +56,7 @@ def formsemestre(formsemestre_id: int):
formsemetre = models.FormSemestre.query.filter_by(id=formsemestre_id).first_or_404()
# Mise en forme des données
data = formsemetre.to_dict()
data = formsemetre.to_dict_api()
return jsonify(data)
@ -103,7 +103,7 @@ def formsemestre_apo(etape_apo: str):
FormSemestreEtape.formsemestre_id == FormSemestre.id,
)
return jsonify([formsemestre.to_dict() for formsemestre in formsemestres])
return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres])
@bp.route(

View File

@ -141,6 +141,28 @@ class FormSemestre(db.Model):
d["responsables"] = [u.id for u in self.responsables]
return d
def to_dict_api(self):
"""
Un dict avec les informations sur le semestre destiné à l'api
"""
d = dict(self.__dict__)
d.pop("_sa_instance_state", None)
d["formsemestre_id"] = self.id
d["titre_num"] = self.titre_num()
if self.date_debut:
d["date_debut"] = self.date_debut.strftime("%d/%m/%Y")
d["date_debut_iso"] = self.date_debut.isoformat()
else:
d["date_debut"] = d["date_debut_iso"] = ""
if self.date_fin:
d["date_fin"] = self.date_fin.strftime("%d/%m/%Y")
d["date_fin_iso"] = self.date_fin.isoformat()
else:
d["date_fin"] = d["date_fin_iso"] = ""
d["responsables"] = [u.id for u in self.responsables]
d["titre_court"] = self.formation.acronyme
return d
def get_infos_dict(self) -> dict:
"""Un dict avec des informations sur le semestre
pour les bulletins et autres templates
@ -373,6 +395,7 @@ class FormSemestre(db.Model):
if self.semestre_id == sco_codes_parcours.NO_SEMESTRE_ID:
return self.titre
return f"{self.titre} {self.formation.get_parcours().SESSION_NAME} {self.semestre_id}"
# return f"{self.formation.acronyme} S{self.semestre_id}"
def sem_modalite(self) -> str:
"""Le semestre et la modalité, ex "S2 FI" ou "S3 APP" """

View File

@ -19,62 +19,98 @@ Utilisation :
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# absences
def test_absences():
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/etudid/<int:etudid>",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/nip/<int:nip>",
SCODOC_URL + "/ScoDoc/api/absences/etudid/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
abs = r.json()[0]
fields_OK = verify_fields(abs, fields)
assert r.status_code == 200
assert fields_OK is True
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/ine/<int:ine>",
SCODOC_URL + "/ScoDoc/api/absences/nip/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
abs = r.json()[0]
fields_OK = verify_fields(abs, fields)
assert r.status_code == 200
assert fields_OK is True
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/ine/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
abs = r.json()[0]
fields_OK = verify_fields(abs, fields)
assert r.status_code == 200
assert fields_OK is True
# absences_justify
def test_absences_justify():
fields = ["jour", "matin", "estabs", "estjust", "description", "begin", "end"]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/etudid/1/just",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
abs = r.json()[0]
fields_OK = verify_fields(abs, fields)
assert r.status_code == 200
assert fields_OK is True
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/nip/1/just",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
abs = r.json()[0]
fields_OK = verify_fields(abs, fields)
assert r.status_code == 200
assert fields_OK is True
r = requests.get(
SCODOC_URL + "/ScoDoc/api/absences/ine/1/just",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
abs = r.json()[0]
fields_OK = verify_fields(abs, fields)
assert r.status_code == 200
assert fields_OK is True
# abs_groupe_etat
def test_abs_groupe_etat():
r = requests.get(
SCODOC_URL
+ "/ScoDoc/api/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
# def test_abs_groupe_etat():
# r = requests.get(
# SCODOC_URL
# + "/ScoDoc/api/absences/abs_group_etat/?group_id=<int:group_id>&date_debut=date_debut&date_fin=date_fin",
# headers=HEADERS,
# verify=CHECK_CERTIFICATE,
# )
# assert r.status_code == 200

View File

@ -20,15 +20,45 @@ Utilisation :
import requests
from tests.api.setup_test_api import SCODOC_URL, CHECK_CERTIFICATE, HEADERS
from tests.api.tools_test_api import verify_fields
# evaluations
def test_evaluations():
fields = [
"moduleimpl_id",
"jour",
"heure_debut",
"description",
"coefficient",
"publish_incomplete",
"numero",
"id",
"heure_fin",
"note_max",
"visibulletin",
"evaluation_type",
"evaluation_id",
"jouriso",
"duree",
"descrheure",
"matin",
"apresmidi",
]
r = requests.get(
SCODOC_URL + "/ScoDoc/api/evaluations/1",
headers=HEADERS,
verify=CHECK_CERTIFICATE,
)
eval = r.json()[0]
fields_OK = verify_fields(eval, fields)
assert r.status_code == 200
# assert len(r.json()) == 1
assert fields_OK is True
# evaluation_notes