Fix: API edt, tests unit API

This commit is contained in:
Emmanuel Viennet 2023-11-15 00:17:47 +01:00
parent 676ae47d69
commit b8f5f961e8
2 changed files with 8 additions and 3 deletions

View File

@ -41,7 +41,7 @@ from app.scodoc.sco_exceptions import ScoValueError
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
def get_ics_filename(edt_id: str) -> str: def get_ics_filename(edt_id: str) -> str | None:
"Le chemin vers l'ics de cet edt_id" "Le chemin vers l'ics de cet edt_id"
edt_ics_path = ScoDocSiteConfig.get("edt_ics_path") edt_ics_path = ScoDocSiteConfig.get("edt_ics_path")
if not edt_ics_path.strip(): if not edt_ics_path.strip():
@ -62,6 +62,8 @@ def formsemestre_load_calendar(
"accès aux emplois du temps non configuré pour ce semestre (pas d'edt_id)" "accès aux emplois du temps non configuré pour ce semestre (pas d'edt_id)"
) )
ics_filename = get_ics_filename(edt_id) ics_filename = get_ics_filename(edt_id)
if ics_filename is None:
raise ScoValueError("accès aux emplois du temps non configuré (pas de chemin)")
try: try:
with open(ics_filename, "rb") as file: with open(ics_filename, "rb") as file:
log(f"Loading edt from {ics_filename}") log(f"Loading edt from {ics_filename}")

View File

@ -70,6 +70,9 @@ def test_permissions(api_headers):
# par défaut, on passe tous les arguments de all_args # par défaut, on passe tous les arguments de all_args
endpoint_args = { endpoint_args = {
"api.formsemestres_query": {}, "api.formsemestres_query": {},
"api.formsemestre_edt": {
"formsemestre_id": 1,
},
} }
for rule in api_rules: for rule in api_rules:
args = endpoint_args.get(rule.endpoint, all_args) args = endpoint_args.get(rule.endpoint, all_args)