From 000416f24e0271c62c813625f02b0544f666b75a Mon Sep 17 00:00:00 2001 From: Antoine Van Elstraete Date: Tue, 8 Sep 2026 16:19:27 +0200 Subject: [PATCH] feat(M13): complete test fixtures, shared conftest, and coverage >= 90% MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finalize M13 test and coverage milestone: tests/fixtures/pronote-6e.ics (new): - Anonymized iCal fixture for Classe de 6e (3 VEVENTs: SVT lesson with homework block, Histoire-Géo modified lesson, all-day school outing) - Same structure as pronote-4e.ics, no secrets or real data tests/conftest.py: - Added sample_message fixture (Message with MessageType.INFORMATION) - Integrated sample_message into pronote_data fixture (messages=[sample_message]) - Sphinx/reST docstring with :return: and :rtype: .gitignore: - Fixed typo: .worktress/ -> .worktrees/ (line 56) pyproject.toml: - Added ".worktrees" to ruff extend-exclude to prevent ruff format --check . from scanning worktree files TODO.md: - Checked M13 items: tests/fixtures/ and tests/conftest.py Validation: 627 tests pass, coverage 95.67% (threshold 90%), ruff/mypy/ bandit/pre-commit all green. Co-authored-by: opencode/coder --- .gitignore | 2 +- TODO.md | 4 +-- pyproject.toml | 2 +- tests/conftest.py | 24 +++++++++++++-- tests/fixtures/pronote-6e.ics | 56 +++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 tests/fixtures/pronote-6e.ics diff --git a/.gitignore b/.gitignore index eaf59cb..16a6a24 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,7 @@ Thumbs.db # --- Local scratch / WIP files --- FIXME_* TEST_* -.worktress/ +.worktrees/ # --- Logs --- *.log diff --git a/TODO.md b/TODO.md index 533cba2..073cbb4 100644 --- a/TODO.md +++ b/TODO.md @@ -257,8 +257,8 @@ Exposer le lancement du pipeline via une interface en ligne de commande. Couvrir l'ensemble du code par des tests sans réseau, avec fixtures anonymisées, jusqu'à ≥ 90 %. -- [ ] Créer `tests/fixtures/` : `pronote-4e.ics`, `pronote-6e.ics`, `theoretical.json`, `school_holidays.json`, `blog_rss.xml` (anonymisés, sans `icalsecurise`). -- [ ] Créer `tests/conftest.py` : fixtures partagées (sample_lesson, sample_cancelled_lesson, sample_homework, sample_school_event, sample_message, sample_pronote_data…). +- [x] Créer `tests/fixtures/` : `pronote-4e.ics`, `pronote-6e.ics`, `theoretical.json`, `school_holidays.json`, `blog_rss.xml` (anonymisés, sans `icalsecurise`). +- [x] Créer `tests/conftest.py` : fixtures partagées (sample_lesson, sample_cancelled_lesson, sample_homework, sample_school_event, sample_message, sample_pronote_data…). - [x] Écrire `tests/unit/` : `test_models`, `test_parsing` (iCal), `test_uid`, `test_redaction`, `test_diff`, `test_sync`. - [x] Couvrir les régressions M4 : signature réelle de `ParentClient`, ENT autorisé/inconnu, erreur vs résultat vide, `STATUS:CANCELLED` sans catégorie, plusieurs devoirs à la même date, filtrage `pronotepy` sur la date cible et stabilité d'identité entre sources. - [x] Écrire `tests/integration/` : `test_pipeline`, `test_caldav` (mocké), `test_xmpp` (mocké). diff --git a/pyproject.toml b/pyproject.toml index 9b17fd5..6d124b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ skips = ["B101"] # Ignorer les assertions (utilisées dans les tests) line-length = 100 target-version = "py313" # Exclure la documentation markdown (ruff format ne doit pas toucher aux blocs de code Python inclus) -extend-exclude = ["GUIDE_DEV_PYTHON.md"] +extend-exclude = ["GUIDE_DEV_PYTHON.md", ".worktrees"] [tool.ruff.lint] select = [ diff --git a/tests/conftest.py b/tests/conftest.py index d92059a..a94e91c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,6 +14,7 @@ from pydantic import SecretStr from pronote_sync.config.settings import CalDAVSettings from pronote_sync.models.agenda import Lesson, LessonStatus, SchoolEvent, SchoolEventKind from pronote_sync.models.homework import Homework +from pronote_sync.models.message import Message, MessageType from pronote_sync.models.pronote import PronoteData @@ -85,19 +86,38 @@ def caldav_settings() -> CalDAVSettings: ) +@pytest.fixture +def sample_message() -> Message: + """Message Pronote pour les tests. + + :return: Message Pronote de test. + :rtype: Message + """ + return Message( + id="msg-001", + type=MessageType.INFORMATION, + title="Information de rentrée", + content="La rentrée est prévue le 1er septembre.", + author="Administration", + date=datetime(2026, 1, 15, 9, 0), + read=False, + ) + + @pytest.fixture def pronote_data( sample_lesson: Lesson, sample_cancelled_lesson: Lesson, sample_homework: Homework, sample_school_event: SchoolEvent, + sample_message: Message, ) -> PronoteData: - """Données Pronote de test avec des cours, devoirs et événements.""" + """Données Pronote de test avec des cours, devoirs, événements et messages.""" return PronoteData( lessons=[sample_lesson, sample_cancelled_lesson], homeworks=[sample_homework], school_events=[sample_school_event], - messages=[], + messages=[sample_message], target_date=date(2026, 1, 15), generated_at=datetime(2026, 1, 15, 0, 0), ) diff --git a/tests/fixtures/pronote-6e.ics b/tests/fixtures/pronote-6e.ics new file mode 100644 index 0000000..a0ef5a9 --- /dev/null +++ b/tests/fixtures/pronote-6e.ics @@ -0,0 +1,56 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Index Education//Pronote//FR +X-WR-CALNAME:Classe de 6e +BEGIN:VEVENT +UID:Edt_22222@index-education.net-20260908T140000Z-Index-Education +DTSTAMP:20260908T140000Z +DTSTART:20260908T140000Z +DTEND:20260908T150000Z +SUMMARY:SVT +CATEGORIES:Cours +DESCRIPTION:
+ Matière : SVT + Professeur : M. Dubois + Salle : 104 + Groupe : Classe entière + + Contenu pédagogique : + + Découverte de la cellule et de ses constituants. + Pour le 15/09/2026 : + + Lire le chapitre 2 et schématiser une cellule végétale. + Donné le 08/09/2026 : + + Lire le chapitre 2 et schématiser une cellule végétale. +
+END:VEVENT +BEGIN:VEVENT +UID:Edt_33333@index-education.net-20260908T140000Z-Index-Education +DTSTAMP:20260908T140000Z +DTSTART:20260909T100000Z +DTEND:20260909T110000Z +SUMMARY:Histoire-Géographie +CATEGORIES:Cours - Cours modifié +DESCRIPTION:
+ Matière : Histoire-Géographie + Professeur : Mme Lefevre + Salle : 203 + Groupe : Classe entière + + Contenu pédagogique : + + Les grands repères du temps long : la Préhistoire. +
+END:VEVENT +BEGIN:VEVENT +UID:Edt_44444@index-education.net-20260908T140000Z-Index-Education +DTSTAMP:20260908T140000Z +DTSTART;VALUE=DATE:20260928 +DTEND;VALUE=DATE:20260929 +SUMMARY:Sortie pédagogique +CATEGORIES:Sortie scolaire +DESCRIPTION:Journée de sortie pédagogique au musée d'histoire naturelle. +END:VEVENT +END:VCALENDAR