2022-03-09 16:52:07 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""Test Logos
|
|
|
|
|
|
|
|
Utilisation :
|
|
|
|
créer les variables d'environnement: (indiquer les valeurs
|
|
|
|
pour le serveur ScoDoc que vous voulez interroger)
|
|
|
|
|
|
|
|
export SCODOC_URL="https://scodoc.xxx.net/"
|
|
|
|
export SCODOC_USER="xxx"
|
|
|
|
export SCODOC_PASSWD="xxx"
|
|
|
|
export CHECK_CERTIFICATE=0 # ou 1 si serveur de production avec certif SSL valide
|
|
|
|
|
|
|
|
(on peut aussi placer ces valeurs dans un fichier .env du répertoire tests/api).
|
|
|
|
|
|
|
|
Lancer :
|
|
|
|
pytest tests/api/test_api_formations.py
|
|
|
|
"""
|
2022-03-10 17:43:12 +01:00
|
|
|
|
2022-03-09 16:52:07 +01:00
|
|
|
import requests
|
|
|
|
|
2023-04-06 10:38:31 +02:00
|
|
|
from app.scodoc import sco_utils as scu
|
2024-06-21 00:53:52 +02:00
|
|
|
from tests.api.setup_test_api import (
|
|
|
|
api_admin_headers,
|
|
|
|
api_headers,
|
|
|
|
API_URL,
|
|
|
|
CHECK_CERTIFICATE,
|
|
|
|
GET,
|
|
|
|
POST_JSON,
|
|
|
|
)
|
2022-06-15 16:01:00 +02:00
|
|
|
from tests.api.tools_test_api import (
|
|
|
|
verify_fields,
|
|
|
|
FORMATION_EXPORT_FIELDS,
|
|
|
|
FORMATION_EXPORT_UE_FIELDS,
|
|
|
|
FORMATION_EXPORT_UE_MATIERE_FIELDS,
|
|
|
|
FORMATION_EXPORT_UE_MATIERE_MODULE_FIELDS,
|
|
|
|
FORMATION_EXPORT_UE_MATIERE_MODULE_COEF_FIELDS,
|
|
|
|
MODULE_FIELDS,
|
2022-06-21 15:59:12 +02:00
|
|
|
REF_COMP_FIELDS,
|
2022-06-15 16:01:00 +02:00
|
|
|
)
|
2022-05-09 16:26:23 +02:00
|
|
|
from tests.api.tools_test_api import FORMATION_FIELDS, MODIMPL_FIELDS
|
2022-05-03 16:15:04 +02:00
|
|
|
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_formations_ids(api_headers):
|
|
|
|
"""
|
2022-05-09 16:26:23 +02:00
|
|
|
Route: /formations_ids
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-05-04 23:11:20 +02:00
|
|
|
API_URL + "/formations_ids",
|
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-04-13 12:39:10 +02:00
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-05-04 23:11:20 +02:00
|
|
|
formations_ids = r.json()
|
|
|
|
# Une liste non vide d'entiers
|
|
|
|
assert isinstance(formations_ids, list)
|
|
|
|
assert len(formations_ids) > 0
|
|
|
|
assert all(isinstance(x, int) for x in formations_ids)
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_formations_by_id(api_headers):
|
|
|
|
"""
|
2022-05-09 16:26:23 +02:00
|
|
|
Route: /formation/<int:formation_id>
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-06-15 16:01:00 +02:00
|
|
|
id_formation = 1
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-06-15 16:01:00 +02:00
|
|
|
f"{API_URL}/formation/{id_formation}",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-04-13 12:39:10 +02:00
|
|
|
)
|
2022-05-04 23:11:20 +02:00
|
|
|
assert r.status_code == 200
|
2022-05-03 16:15:04 +02:00
|
|
|
formation = r.json()
|
2022-05-09 16:26:23 +02:00
|
|
|
assert verify_fields(formation, FORMATION_FIELDS) is True
|
2022-06-15 16:01:00 +02:00
|
|
|
assert isinstance(formation["dept_id"], int)
|
|
|
|
assert isinstance(formation["acronyme"], str)
|
|
|
|
assert isinstance(formation["titre_officiel"], str)
|
|
|
|
assert isinstance(formation["formation_code"], str)
|
|
|
|
assert formation["code_specialite"] is None or isinstance(
|
|
|
|
formation["code_specialite"], str
|
|
|
|
)
|
|
|
|
assert isinstance(formation["id"], int)
|
|
|
|
assert isinstance(formation["titre"], str)
|
|
|
|
assert isinstance(formation["version"], int)
|
|
|
|
assert isinstance(formation["type_parcours"], int)
|
|
|
|
assert formation["referentiel_competence_id"] is None or isinstance(
|
|
|
|
formation["referentiel_competence_id"], int
|
|
|
|
)
|
|
|
|
assert isinstance(formation["formation_id"], int)
|
|
|
|
|
|
|
|
assert id_formation == formation["formation_id"]
|
|
|
|
assert id_formation == formation["id"]
|
|
|
|
|
|
|
|
r1 = requests.get(
|
|
|
|
f"{API_URL}/formation/{formation['formation_id']}",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-15 16:01:00 +02:00
|
|
|
)
|
|
|
|
assert r1.status_code == 200
|
|
|
|
formation1 = r1.json()
|
|
|
|
|
|
|
|
assert formation == formation1
|
|
|
|
|
|
|
|
# ERROR
|
|
|
|
id_formation_inexistant = 1516476846861656351
|
|
|
|
r_error = requests.get(
|
|
|
|
f"{API_URL}/formation/{id_formation_inexistant}",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-15 16:01:00 +02:00
|
|
|
)
|
|
|
|
assert r_error.status_code == 404
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-04-13 12:39:10 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_formation_export(api_headers):
|
|
|
|
"""
|
2022-07-29 16:19:40 +02:00
|
|
|
Route: /formation/<int:formation_id>/export
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-07-29 16:19:40 +02:00
|
|
|
API_URL + "/formation/1/export",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-04-13 12:39:10 +02:00
|
|
|
)
|
2022-05-04 23:11:20 +02:00
|
|
|
assert r.status_code == 200
|
2022-05-03 16:15:04 +02:00
|
|
|
export_formation = r.json()
|
2022-06-15 16:01:00 +02:00
|
|
|
assert verify_fields(export_formation, FORMATION_EXPORT_FIELDS) is True
|
|
|
|
assert isinstance(export_formation["acronyme"], str)
|
|
|
|
assert isinstance(export_formation["titre_officiel"], str)
|
|
|
|
assert isinstance(export_formation["formation_code"], str)
|
|
|
|
assert export_formation["code_specialite"] is None or isinstance(
|
|
|
|
export_formation["code_specialite"], str
|
|
|
|
)
|
|
|
|
assert isinstance(export_formation["titre"], str)
|
|
|
|
assert isinstance(export_formation["version"], int)
|
|
|
|
assert isinstance(export_formation["type_parcours"], int)
|
|
|
|
assert export_formation["referentiel_competence_id"] is None or isinstance(
|
|
|
|
export_formation["referentiel_competence_id"], int
|
|
|
|
)
|
|
|
|
assert isinstance(export_formation["ue"], list)
|
|
|
|
|
|
|
|
ues = export_formation["ue"]
|
|
|
|
|
|
|
|
for ue in ues:
|
|
|
|
assert verify_fields(ue, FORMATION_EXPORT_UE_FIELDS) is True
|
|
|
|
assert isinstance(ue["acronyme"], str)
|
|
|
|
assert isinstance(ue["numero"], int)
|
|
|
|
assert isinstance(ue["titre"], str)
|
|
|
|
assert isinstance(ue["type"], int)
|
|
|
|
assert isinstance(ue["ue_code"], str)
|
|
|
|
assert isinstance(ue["ects"], float)
|
|
|
|
assert isinstance(ue["is_external"], bool)
|
|
|
|
assert isinstance(ue["code_apogee"], str)
|
|
|
|
assert isinstance(ue["coefficient"], float)
|
|
|
|
assert isinstance(ue["semestre_idx"], int)
|
|
|
|
assert isinstance(ue["color"], str)
|
|
|
|
assert isinstance(ue["reference"], int)
|
|
|
|
assert isinstance(ue["matiere"], list)
|
2022-05-03 16:15:04 +02:00
|
|
|
|
2022-06-15 16:01:00 +02:00
|
|
|
matieres = ue["matiere"]
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-06-15 16:01:00 +02:00
|
|
|
for matiere in matieres:
|
|
|
|
assert verify_fields(matiere, FORMATION_EXPORT_UE_MATIERE_FIELDS)
|
|
|
|
assert isinstance(matiere["titre"], str)
|
|
|
|
assert isinstance(matiere["numero"], int)
|
|
|
|
assert isinstance(matiere["module"], list)
|
|
|
|
|
|
|
|
modules = matiere["module"]
|
|
|
|
for module in modules:
|
|
|
|
assert verify_fields(module, FORMATION_EXPORT_UE_MATIERE_MODULE_FIELDS)
|
|
|
|
assert isinstance(module["titre"], str)
|
|
|
|
assert isinstance(module["abbrev"], str)
|
|
|
|
assert isinstance(module["code"], str)
|
|
|
|
assert isinstance(module["heures_cours"], float)
|
|
|
|
assert isinstance(module["heures_td"], float)
|
|
|
|
assert isinstance(module["heures_tp"], float)
|
|
|
|
assert isinstance(module["coefficient"], float)
|
|
|
|
assert isinstance(module["ects"], str)
|
|
|
|
assert isinstance(module["semestre_id"], int)
|
|
|
|
assert isinstance(module["numero"], int)
|
|
|
|
assert isinstance(module["code_apogee"], str)
|
|
|
|
assert isinstance(module["module_type"], int)
|
|
|
|
assert isinstance(module["coefficients"], list)
|
|
|
|
|
|
|
|
coefficients = module["coefficients"]
|
|
|
|
for coef in coefficients:
|
|
|
|
assert verify_fields(
|
|
|
|
coef, FORMATION_EXPORT_UE_MATIERE_MODULE_COEF_FIELDS
|
|
|
|
)
|
|
|
|
assert isinstance(coef["ue_reference"], str)
|
|
|
|
assert isinstance(coef["coef"], str)
|
|
|
|
|
|
|
|
# ERROR
|
|
|
|
id_formation_inexistant = 1516476846861656351
|
|
|
|
r_error = requests.get(
|
2022-07-29 16:19:40 +02:00
|
|
|
f"{API_URL}/formation/export/{id_formation_inexistant}",
|
2022-06-15 16:01:00 +02:00
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-15 16:01:00 +02:00
|
|
|
)
|
|
|
|
assert r_error.status_code == 404
|
2022-05-09 16:26:23 +02:00
|
|
|
|
|
|
|
|
2023-01-31 19:19:00 +01:00
|
|
|
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,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2023-01-31 19:19:00 +01:00
|
|
|
)
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_moduleimpl(api_headers):
|
|
|
|
"""
|
2022-05-09 16:26:23 +02:00
|
|
|
Route: /formation/moduleimpl/<int:moduleimpl_id>
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
2022-06-15 16:01:00 +02:00
|
|
|
moduleimpl_id = 1
|
2022-03-10 17:43:12 +01:00
|
|
|
r = requests.get(
|
2022-07-29 16:19:40 +02:00
|
|
|
f"{API_URL}/moduleimpl/{moduleimpl_id}",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
2022-04-13 12:39:10 +02:00
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-04-13 12:39:10 +02:00
|
|
|
)
|
2022-03-10 17:43:12 +01:00
|
|
|
assert r.status_code == 200
|
2022-05-04 23:11:20 +02:00
|
|
|
moduleimpl = r.json()
|
2022-05-09 16:26:23 +02:00
|
|
|
assert verify_fields(moduleimpl, MODIMPL_FIELDS) is True
|
2022-06-15 16:01:00 +02:00
|
|
|
assert isinstance(moduleimpl["id"], int)
|
|
|
|
assert isinstance(moduleimpl["responsable_id"], int)
|
|
|
|
assert isinstance(moduleimpl["module_id"], int)
|
|
|
|
assert isinstance(moduleimpl["formsemestre_id"], int)
|
|
|
|
assert moduleimpl["computation_expr"] is None or isinstance(
|
|
|
|
moduleimpl["computation_expr"], str
|
|
|
|
)
|
|
|
|
assert isinstance(moduleimpl["moduleimpl_id"], int)
|
|
|
|
assert isinstance(moduleimpl["ens"], list)
|
|
|
|
assert isinstance(moduleimpl["module"], dict)
|
|
|
|
|
|
|
|
module = moduleimpl["module"]
|
|
|
|
assert verify_fields(module, MODULE_FIELDS)
|
|
|
|
assert isinstance(module["heures_cours"], float)
|
|
|
|
assert isinstance(module["semestre_id"], int)
|
|
|
|
assert isinstance(module["heures_td"], float)
|
|
|
|
assert isinstance(module["numero"], int)
|
|
|
|
assert isinstance(module["heures_tp"], float)
|
|
|
|
assert isinstance(module["code_apogee"], str)
|
|
|
|
assert isinstance(module["titre"], str)
|
|
|
|
assert isinstance(module["coefficient"], float)
|
|
|
|
assert isinstance(module["module_type"], int)
|
|
|
|
assert isinstance(module["id"], int)
|
|
|
|
assert module["ects"] is None or isinstance(module["ects"], str)
|
|
|
|
assert isinstance(module["abbrev"], str)
|
|
|
|
assert isinstance(module["ue_id"], int)
|
|
|
|
assert isinstance(module["code"], str)
|
|
|
|
assert isinstance(module["formation_id"], int)
|
|
|
|
assert isinstance(module["matiere_id"], int)
|
|
|
|
assert isinstance(module["module_id"], int)
|
|
|
|
|
|
|
|
assert moduleimpl_id == moduleimpl["id"]
|
|
|
|
assert moduleimpl_id == moduleimpl["moduleimpl_id"]
|
|
|
|
|
|
|
|
r1 = requests.get(
|
2022-07-29 16:19:40 +02:00
|
|
|
f"{API_URL}/moduleimpl/{moduleimpl['moduleimpl_id']}",
|
2022-06-15 16:01:00 +02:00
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-15 16:01:00 +02:00
|
|
|
)
|
|
|
|
assert r1.status_code == 200
|
|
|
|
moduleimpl1 = r1.json()
|
|
|
|
|
|
|
|
assert moduleimpl == moduleimpl1
|
|
|
|
|
|
|
|
# ERROR
|
|
|
|
id_formation_inexistant = 1516476846861656351
|
|
|
|
r_error = requests.get(
|
|
|
|
f"{API_URL}/formation/moduleimpl/{id_formation_inexistant}",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-15 16:01:00 +02:00
|
|
|
)
|
|
|
|
assert r_error.status_code == 404
|
2022-03-09 16:52:07 +01:00
|
|
|
|
2022-05-03 16:15:04 +02:00
|
|
|
|
2022-05-04 23:11:20 +02:00
|
|
|
def test_referentiel_competences(api_headers):
|
|
|
|
"""
|
2022-05-09 16:26:23 +02:00
|
|
|
Route: "/formation/<int:formation_id>/referentiel_competences",
|
2022-05-04 23:11:20 +02:00
|
|
|
"""
|
|
|
|
r = requests.get(
|
2022-06-21 15:59:12 +02:00
|
|
|
f"{API_URL}/formation/1/referentiel_competences",
|
2022-05-04 23:11:20 +02:00
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-05-04 23:11:20 +02:00
|
|
|
)
|
2022-04-13 12:39:10 +02:00
|
|
|
assert r.status_code == 200
|
2022-06-21 15:59:12 +02:00
|
|
|
|
|
|
|
ref_comp = r.json()
|
|
|
|
assert verify_fields(ref_comp, REF_COMP_FIELDS) is True
|
|
|
|
assert isinstance(ref_comp["dept_id"], int)
|
|
|
|
assert isinstance(ref_comp["annexe"], str)
|
|
|
|
assert isinstance(ref_comp["specialite"], str)
|
|
|
|
assert isinstance(ref_comp["specialite_long"], str)
|
|
|
|
assert isinstance(ref_comp["type_structure"], str)
|
|
|
|
assert isinstance(ref_comp["type_departement"], str)
|
|
|
|
assert isinstance(ref_comp["type_titre"], str)
|
|
|
|
assert isinstance(ref_comp["version_orebut"], str)
|
|
|
|
assert isinstance(ref_comp["scodoc_date_loaded"], str)
|
|
|
|
assert isinstance(ref_comp["scodoc_orig_filename"], str)
|
|
|
|
assert isinstance(ref_comp["competences"], dict)
|
|
|
|
assert isinstance(ref_comp["parcours"], dict)
|
|
|
|
|
|
|
|
# ERROR
|
|
|
|
id_formation_inexistant = 1516476846861656351
|
|
|
|
r_error = requests.get(
|
|
|
|
f"{API_URL}/formation/{id_formation_inexistant}/referentiel_competences",
|
|
|
|
headers=api_headers,
|
|
|
|
verify=CHECK_CERTIFICATE,
|
2023-04-06 10:38:31 +02:00
|
|
|
timeout=scu.SCO_TEST_API_TIMEOUT,
|
2022-06-21 15:59:12 +02:00
|
|
|
)
|
|
|
|
assert r_error.status_code == 404
|
2024-06-21 00:53:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_api_ue_apo(api_admin_headers):
|
|
|
|
"""Routes
|
2024-07-03 21:32:33 +02:00
|
|
|
/formation/ue/<int:ue_id>
|
|
|
|
/formation/ue/<int:ue_id>/set_code_apogee/<string:code_apogee>
|
|
|
|
/formation/ue/<int:ue_id>/set_code_apogee_rcue/<string:code_apogee>
|
2024-06-21 00:53:52 +02:00
|
|
|
"""
|
|
|
|
ue_id = 1
|
2024-07-03 21:32:33 +02:00
|
|
|
ue = GET(path=f"/formation/ue/{ue_id}", headers=api_admin_headers)
|
2024-06-21 00:53:52 +02:00
|
|
|
assert ue["id"] == ue_id
|
2024-07-03 21:32:33 +02:00
|
|
|
r = POST_JSON(
|
|
|
|
f"/formation/ue/{ue_id}/set_code_apogee/APOUE", {}, api_admin_headers, raw=True
|
|
|
|
)
|
2024-06-21 00:53:52 +02:00
|
|
|
assert r.text == "APOUE"
|
|
|
|
r = POST_JSON(
|
2024-07-03 21:32:33 +02:00
|
|
|
f"/formation/ue/{ue_id}/set_code_apogee_rcue/APORCUE",
|
|
|
|
{},
|
|
|
|
api_admin_headers,
|
|
|
|
raw=True,
|
2024-06-21 00:53:52 +02:00
|
|
|
)
|
|
|
|
assert r.text == "APORCUE"
|
2024-07-03 21:32:33 +02:00
|
|
|
ue = GET(path=f"/formation/ue/{ue_id}", headers=api_admin_headers)
|
2024-06-21 00:53:52 +02:00
|
|
|
assert ue["code_apogee"] == "APOUE"
|
|
|
|
assert ue["code_apogee_rcue"] == "APORCUE"
|
|
|
|
|
|
|
|
|
|
|
|
def test_api_module_apo(api_admin_headers):
|
|
|
|
"""Routes
|
2024-07-03 21:32:33 +02:00
|
|
|
/formation/module/<int:module_id>
|
|
|
|
/formation/module/<int:module_id>/set_code_apogee/<string:code_apogee>
|
2024-06-21 00:53:52 +02:00
|
|
|
"""
|
|
|
|
module_id = 1
|
2024-07-03 21:32:33 +02:00
|
|
|
module = GET(path=f"/formation/module/{module_id}", headers=api_admin_headers)
|
2024-06-21 00:53:52 +02:00
|
|
|
assert module["id"] == module_id
|
|
|
|
assert module["code_apogee"] == ""
|
|
|
|
r = POST_JSON(
|
2024-07-03 21:32:33 +02:00
|
|
|
f"/formation/module/{module_id}/set_code_apogee/APOMOD",
|
|
|
|
{},
|
|
|
|
api_admin_headers,
|
|
|
|
raw=True,
|
2024-06-21 00:53:52 +02:00
|
|
|
)
|
|
|
|
assert r.text == "APOMOD"
|
2024-07-03 21:32:33 +02:00
|
|
|
module = GET(path=f"/formation/module/{module_id}", headers=api_admin_headers)
|
2024-06-21 00:53:52 +02:00
|
|
|
assert module["code_apogee"] == "APOMOD"
|
2024-07-03 21:32:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_api_module_edit(api_admin_headers):
|
|
|
|
"""Routes
|
|
|
|
/formation/module/<int:module_id>/edit
|
|
|
|
"""
|
|
|
|
module_id = 1
|
|
|
|
module = POST_JSON(
|
|
|
|
f"/formation/module/{module_id}/edit",
|
|
|
|
{"heures_cours": 16, "semestre_id": 1, "abbrev": "ALLO"},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert module["id"] == module_id
|
|
|
|
assert module["heures_cours"] == 16
|
|
|
|
assert module["semestre_id"] == 1
|
|
|
|
assert module["abbrev"] == "ALLO"
|
|
|
|
# tente de changer l'UE: ne devrait rien faire:
|
|
|
|
ue_id = module["ue_id"]
|
|
|
|
module = POST_JSON(
|
|
|
|
f"/formation/module/{module_id}/edit",
|
|
|
|
{"ue_id": 666},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert module["ue_id"] == ue_id
|
|
|
|
# tente de changer la formation: ne devrait rien faire:
|
|
|
|
formation_id = module["formation_id"]
|
|
|
|
module = POST_JSON(
|
|
|
|
f"/formation/module/{module_id}/edit",
|
|
|
|
{"formation_id": 666},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert module["formation_id"] == formation_id
|
|
|
|
# -- assignation de parcours (ce test suppose que les parcours 1, 2, 3 existent)
|
|
|
|
assert module["parcours"] == []
|
|
|
|
module = POST_JSON(
|
|
|
|
f"/formation/module/{module_id}/edit",
|
|
|
|
{"parcours": [1, 2, 3]},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert sorted(module["parcours"]) == [1, 2, 3]
|
|
|
|
|
|
|
|
|
|
|
|
def test_api_ue_edit(api_admin_headers):
|
|
|
|
"""Routes
|
|
|
|
/formation/ue/<int:ue_id>/edit
|
|
|
|
"""
|
|
|
|
ue_id = 1
|
|
|
|
ue = POST_JSON(
|
|
|
|
f"/formation/ue/{ue_id}/edit",
|
|
|
|
{"titre": "formation test modifiée", "numero": 22},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert ue["id"] == ue_id
|
|
|
|
assert ue["numero"] == 22
|
|
|
|
assert ue["titre"] == "formation test modifiée"
|
|
|
|
|
|
|
|
# tente de changer le niveau de compétence: ne devrait rien faire:
|
|
|
|
niveau_competence_id = ue["niveau_competence_id"]
|
|
|
|
ue = POST_JSON(
|
|
|
|
f"/formation/ue/{ue_id}/edit",
|
|
|
|
{"niveau_competence_id": 666},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert ue["niveau_competence_id"] == niveau_competence_id
|
|
|
|
# tente de changer la formation: ne devrait rien faire:
|
|
|
|
formation_id = ue["formation_id"]
|
|
|
|
ue = POST_JSON(
|
|
|
|
f"/formation/ue/{ue_id}/edit",
|
|
|
|
{"formation_id": 666},
|
|
|
|
api_admin_headers,
|
|
|
|
)
|
|
|
|
assert ue["formation_id"] == formation_id
|