Compare commits

..

2 Commits

Author SHA1 Message Date
leonard_montalbano
85e7818843 ajout des tests unitaires pour formsemestre_apo 2022-06-27 16:12:41 +02:00
leonard_montalbano
35a6427e2f ajout d'étapes apo dans la base de tests unitaires 2022-06-27 16:11:48 +02:00
2 changed files with 121 additions and 12 deletions

View File

@ -40,24 +40,116 @@ def test_formsemestre(api_headers):
""" """
Route: /formsemestre/<id> Route: /formsemestre/<id>
""" """
formsemestre_id = 1
r = requests.get( r = requests.get(
API_URL + "/formsemestre/1", f"{API_URL}/formsemestre/{formsemestre_id}",
headers=api_headers, headers=api_headers,
verify=CHECK_CERTIFICATE, verify=CHECK_CERTIFICATE,
) )
assert r.status_code == 200 assert r.status_code == 200
formsemestre = r.json() formsemestre = r.json()
assert verify_fields(formsemestre, FSEM_FIELDS) assert verify_fields(formsemestre, FSEM_FIELDS)
assert isinstance(formsemestre["block_moyennes"], bool)
assert isinstance(formsemestre["bul_bgcolor"], str)
assert isinstance(formsemestre["bul_hide_xml"], bool)
assert isinstance(formsemestre["date_debut_iso"], str)
assert isinstance(formsemestre["date_debut"], str)
assert isinstance(formsemestre["date_fin_iso"], str)
assert isinstance(formsemestre["date_fin"], str)
assert isinstance(formsemestre["dept_id"], int)
assert formsemestre["elt_annee_apo"] is None or isinstance(
formsemestre["elt_annee_apo"], str
)
assert formsemestre["elt_sem_apo"] is None or isinstance(
formsemestre["elt_sem_apo"], str
)
assert isinstance(formsemestre["ens_can_edit_eval"], bool)
assert isinstance(formsemestre["etat"], bool)
assert isinstance(formsemestre["formation_id"], int)
assert isinstance(formsemestre["formsemestre_id"], int)
assert isinstance(formsemestre["gestion_compensation"], bool)
assert isinstance(formsemestre["gestion_semestrielle"], bool)
assert isinstance(formsemestre["id"], int)
assert isinstance(formsemestre["modalite"], str)
assert isinstance(formsemestre["resp_can_change_ens"], bool)
assert isinstance(formsemestre["resp_can_edit"], bool)
assert isinstance(formsemestre["responsables"], list)
assert formsemestre["scodoc7_id"] is None or isinstance(
formsemestre["scodoc7_id"], int
)
assert isinstance(formsemestre["semestre_id"], int)
assert isinstance(formsemestre["titre_formation"], str)
assert isinstance(formsemestre["titre_num"], str)
assert isinstance(formsemestre["titre"], str)
### ERROR ###
formsemestre_id_inexistant = 165456165165136513510351
r = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id_inexistant}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
# XXX TODO ajouter une etape_apo dans la base de test def test_formsemestre_apo(api_headers):
# def test_formsemestre_apo(api_headers): """
# r = requests.get( Route: /formsemestre/apo/<string:etape_apo>
# API_URL + "/formation/apo/<string:etape_apo>", """
# headers=api_headers, etape_apo = "A1"
# verify=CHECK_CERTIFICATE, r = requests.get(
# ) f"{API_URL}/formsemestre/apo/{etape_apo}",
# assert r.status_code == 200 headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
list_formsemestre = r.json()
assert isinstance(list_formsemestre, list)
for formsemestre in list_formsemestre:
assert isinstance(formsemestre, dict)
assert verify_fields(formsemestre, FSEM_FIELDS)
assert isinstance(formsemestre["block_moyennes"], bool)
assert isinstance(formsemestre["bul_bgcolor"], str)
assert isinstance(formsemestre["bul_hide_xml"], bool)
assert isinstance(formsemestre["date_debut_iso"], str)
assert isinstance(formsemestre["date_debut"], str)
assert isinstance(formsemestre["date_fin_iso"], str)
assert isinstance(formsemestre["date_fin"], str)
assert isinstance(formsemestre["dept_id"], int)
assert formsemestre["elt_annee_apo"] is None or isinstance(
formsemestre["elt_annee_apo"], str
)
assert formsemestre["elt_sem_apo"] is None or isinstance(
formsemestre["elt_sem_apo"], str
)
assert isinstance(formsemestre["ens_can_edit_eval"], bool)
assert isinstance(formsemestre["etat"], bool)
assert isinstance(formsemestre["formation_id"], int)
assert isinstance(formsemestre["formsemestre_id"], int)
assert isinstance(formsemestre["gestion_compensation"], bool)
assert isinstance(formsemestre["gestion_semestrielle"], bool)
assert isinstance(formsemestre["id"], int)
assert isinstance(formsemestre["modalite"], str)
assert isinstance(formsemestre["resp_can_change_ens"], bool)
assert isinstance(formsemestre["resp_can_edit"], bool)
assert isinstance(formsemestre["responsables"], list)
assert formsemestre["scodoc7_id"] is None or isinstance(
formsemestre["scodoc7_id"], int
)
assert isinstance(formsemestre["semestre_id"], int)
assert isinstance(formsemestre["titre_formation"], str)
assert isinstance(formsemestre["titre_num"], str)
assert isinstance(formsemestre["titre"], str)
### ERROR ###
etape_apo_inexistante = "aoefiaozidaoẑidjnoaiznjd"
r = requests.get(
f"{API_URL}/formsemestre/apo/{etape_apo_inexistante}",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 404
def test_bulletins(api_headers): def test_bulletins(api_headers):

View File

@ -38,7 +38,8 @@ from app.models import (
NotesNotes, NotesNotes,
ApcReferentielCompetences, ApcReferentielCompetences,
ApcCompetence, ApcCompetence,
Absence, FormSemestreEtape, Absence,
FormSemestreEtape,
) )
from app import db from app import db
from app.models.but_refcomp import ( from app.models.but_refcomp import (
@ -486,8 +487,24 @@ def create_etape_apo(formsemestre: FormSemestre):
""" """
Ajoute étape apoge au formsemestre Ajoute étape apoge au formsemestre
""" """
etape_apo = FormSemestreEtape(id=1, formsemestre_id=formsemestre.id, etape_apo="A1") etape_apo1 = FormSemestreEtape(
formsemestre.etapes = etape_apo id=1, formsemestre_id=formsemestre.id, etape_apo="A1"
)
db.session.add(etape_apo1)
etape_apo2 = FormSemestreEtape(
id=2, formsemestre_id=formsemestre.id, etape_apo="A2"
)
db.session.add(etape_apo2)
etape_apo3 = FormSemestreEtape(
id=3, formsemestre_id=formsemestre.id, etape_apo="A3"
)
db.session.add(etape_apo3)
list_etapes = [etape_apo1, etape_apo2, etape_apo3]
formsemestre.etapes = list_etapes
db.session.commit()
def init_test_database(): def init_test_database():