Fix test API formation et ajout d'un test (test_formation_export_with_ids)

This commit is contained in:
Emmanuel Viennet 2023-01-31 15:19:00 -03:00
parent 51ea48a5b5
commit aa5ec8e74c
2 changed files with 23 additions and 11 deletions

View File

@ -114,21 +114,18 @@ def test_formation_export(api_headers):
assert r.status_code == 200 assert r.status_code == 200
export_formation = r.json() export_formation = r.json()
assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True
assert isinstance(export_formation["dept_id"], int)
assert isinstance(export_formation["acronyme"], str) assert isinstance(export_formation["acronyme"], str)
assert isinstance(export_formation["titre_officiel"], str) assert isinstance(export_formation["titre_officiel"], str)
assert isinstance(export_formation["formation_code"], str) assert isinstance(export_formation["formation_code"], str)
assert export_formation["code_specialite"] is None or isinstance( assert export_formation["code_specialite"] is None or isinstance(
export_formation["code_specialite"], str export_formation["code_specialite"], str
) )
assert isinstance(export_formation["id"], int)
assert isinstance(export_formation["titre"], str) assert isinstance(export_formation["titre"], str)
assert isinstance(export_formation["version"], int) assert isinstance(export_formation["version"], int)
assert isinstance(export_formation["type_parcours"], int) assert isinstance(export_formation["type_parcours"], int)
assert export_formation["referentiel_competence_id"] is None or isinstance( assert export_formation["referentiel_competence_id"] is None or isinstance(
export_formation["referentiel_competence_id"], int export_formation["referentiel_competence_id"], int
) )
assert isinstance(export_formation["formation_id"], int)
assert isinstance(export_formation["ue"], list) assert isinstance(export_formation["ue"], list)
ues = export_formation["ue"] ues = export_formation["ue"]
@ -192,6 +189,23 @@ def test_formation_export(api_headers):
assert r_error.status_code == 404 assert r_error.status_code == 404
def test_formation_export_with_ids(api_headers):
"""
Route: /formation/<int:formation_id>/export_with_ids
"""
r = requests.get(
API_URL + "/formation/1/export_with_ids",
headers=api_headers,
verify=CHECK_CERTIFICATE,
)
assert r.status_code == 200
export_formation = r.json()
assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True
assert isinstance(export_formation["id"], int)
assert isinstance(export_formation["dept_id"], int)
assert isinstance(export_formation["formation_id"], int)
def test_moduleimpl(api_headers): def test_moduleimpl(api_headers):
""" """
Route: /formation/moduleimpl/<int:moduleimpl_id> Route: /formation/moduleimpl/<int:moduleimpl_id>

View File

@ -77,18 +77,16 @@ FORMATION_FIELDS = {
} }
FORMATION_EXPORT_FIELDS = { FORMATION_EXPORT_FIELDS = {
"dept_id", # "dept_id" "id" "formation_id", pas présents sauf si export_with_ids
"acronyme", "acronyme",
"titre_officiel",
"formation_code",
"code_specialite", "code_specialite",
"id", "formation_code",
"titre",
"version",
"type_parcours",
"referentiel_competence_id", "referentiel_competence_id",
"formation_id", "titre_officiel",
"titre",
"type_parcours",
"ue", "ue",
"version",
} }
FORMATION_EXPORT_UE_FIELDS = { FORMATION_EXPORT_UE_FIELDS = {