From 3cea82a7344bf2ea46fca940ca006b98c3e1605d Mon Sep 17 00:00:00 2001 From: Mark007-R Date: Sun, 24 May 2026 13:25:40 +0530 Subject: [PATCH] =?UTF-8?q?sprint:=20mark=20data-dependent=20Day-4=20tests?= =?UTF-8?q?=20with=20requires=5Fdata=20(Day=207=20CI=20fix)=20=E2=80=94=20?= =?UTF-8?q?test=5Fapi=20needs=20models/fraud=5Fmodel.pkl,=20test=5Floader?= =?UTF-8?q?=5Freads=5Fx=5Ftest=5Fand=5Fy=5Ftest=20needs=20data/processed/*?= =?UTF-8?q?.csv;=20both=20DVC-tracked,=20not=20in=20git;=20CI's=20-m=20'no?= =?UTF-8?q?t=20requires=5Fdata'=20now=20finds=20the=20marker=20via=20tests?= =?UTF-8?q?/conftest.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/conftest.py | 19 +++++++++++++++++++ tests/test_api.py | 7 +++++++ tests/test_data_loader.py | 3 +++ 3 files changed, 29 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..f76fedb --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +"""Pytest configuration -- shared markers for the Sentinel test suite. + +Day 7 Phase 6 (2026-05-24). The CI workflow at .github/workflows/ci.yml runs +`pytest tests/ -m "not requires_data"` so the GitHub runner skips tests that +need the DVC-tracked data and trained model artifacts (which are not in git). +This conftest registers the `requires_data` marker so pytest does not emit a +PytestUnknownMarkWarning when the marker is used. +""" + +from __future__ import annotations + + +def pytest_configure(config) -> None: + config.addinivalue_line( + "markers", + "requires_data: test depends on DVC-tracked data and/or the trained " + "model artifact in models/. Skipped in CI; run locally after " + "`dvc repro train`.", + ) diff --git a/tests/test_api.py b/tests/test_api.py index 1f10a86..86ebbcd 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -15,6 +15,13 @@ from fastapi.testclient import TestClient +# The FastAPI app boots from models/fraud_model.pkl + data/processed/X_test.csv, +# neither of which is in git -- they come from `dvc repro train`. CI skips this +# whole module via the `-m "not requires_data"` marker filter; run locally +# after a successful pipeline run. +pytestmark = pytest.mark.requires_data + + @pytest.fixture(scope="module") def client(tmp_path_factory: pytest.TempPathFactory) -> TestClient: tmp_dir = tmp_path_factory.mktemp("api-test") diff --git a/tests/test_data_loader.py b/tests/test_data_loader.py index fc46b19..198d6da 100644 --- a/tests/test_data_loader.py +++ b/tests/test_data_loader.py @@ -5,6 +5,7 @@ from pathlib import Path import pandas as pd +import pytest from src.data.loader import LoaderConfig, SentinelDataLoader, dvc_status @@ -17,6 +18,8 @@ def test_loader_resolves_paths_from_params() -> None: assert paths.model.name == "fraud_model.pkl" +# Reads data/processed/X_test.csv + y_test.csv which are not in git (DVC). +@pytest.mark.requires_data def test_loader_reads_x_test_and_y_test() -> None: loader = SentinelDataLoader() X = loader.load_x_test()