From 0f5176b5534f8fd7559359809333a72e94d5b5bc Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 5 Jan 2024 14:25:26 +0100 Subject: [PATCH] Fix unit test (admission etudiant dans annee courante) --- tests/unit/__init__.py | 11 ++++++++++- tests/unit/test_etudiants.py | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index e8363bc1..6428a4d5 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -19,4 +19,13 @@ def call_view(view_function, *args, **kwargs): def dict_include(d: dict, ref: dict) -> bool: """Checks that all keys in ref are in d, and with the same value.""" - return all((k in d) and (d[k] == ref[k]) for k in ref) + # quick check + ok = all((k in d) and (d[k] == ref[k]) for k in ref) + if ok: + return True + # more details to ease debugging + assert not (ref.keys() - d.keys()), "Keys missing" + # identical keys, check values + for k, v in ref.items(): + assert d[k] == v, "invalid value" + return False diff --git a/tests/unit/test_etudiants.py b/tests/unit/test_etudiants.py index ea8b2d93..47346ca8 100644 --- a/tests/unit/test_etudiants.py +++ b/tests/unit/test_etudiants.py @@ -9,6 +9,7 @@ Utiliser comme: """ import datetime from pathlib import Path +import time from flask import current_app @@ -348,7 +349,7 @@ def test_import_etuds_xlsx(test_client): "nomlycee": "", "apb_classement_gr": 0, "villelycee": "", - "annee": 2023, + "annee": time.localtime()[0], # année courante "specialite": "", "francais": "", "nom_usuel": "",