Compare commits

..

No commits in common. "85e7818843a118c68058951428c551cc7585e96e" and "7cb6dd66c3c0a7b471288f150afe3b1075d3eba9" have entirely different histories.

2 changed files with 12 additions and 121 deletions

View File

@ -40,116 +40,24 @@ def test_formsemestre(api_headers):
""" """
Route: /formsemestre/<id> Route: /formsemestre/<id>
""" """
formsemestre_id = 1
r = requests.get( r = requests.get(
f"{API_URL}/formsemestre/{formsemestre_id}", API_URL + "/formsemestre/1",
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
def test_formsemestre_apo(api_headers): # XXX TODO ajouter une etape_apo dans la base de test
""" # def test_formsemestre_apo(api_headers):
Route: /formsemestre/apo/<string:etape_apo> # r = requests.get(
""" # API_URL + "/formation/apo/<string:etape_apo>",
etape_apo = "A1" # headers=api_headers,
r = requests.get( # verify=CHECK_CERTIFICATE,
f"{API_URL}/formsemestre/apo/{etape_apo}", # )
headers=api_headers, # assert r.status_code == 200
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,8 +38,7 @@ from app.models import (
NotesNotes, NotesNotes,
ApcReferentielCompetences, ApcReferentielCompetences,
ApcCompetence, ApcCompetence,
Absence, Absence, FormSemestreEtape,
FormSemestreEtape,
) )
from app import db from app import db
from app.models.but_refcomp import ( from app.models.but_refcomp import (
@ -487,24 +486,8 @@ def create_etape_apo(formsemestre: FormSemestre):
""" """
Ajoute étape apoge au formsemestre Ajoute étape apoge au formsemestre
""" """
etape_apo1 = FormSemestreEtape( etape_apo = FormSemestreEtape(id=1, formsemestre_id=formsemestre.id, etape_apo="A1")
id=1, formsemestre_id=formsemestre.id, etape_apo="A1" formsemestre.etapes = etape_apo
)
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():