- POST /drivers/upload: validates ZIP, parses INF, persists via DriverStore + Peewee - SHA256 dedup: get_or_create prevents duplicate Driver records - GET /drivers route added to pages.py with driver_data context - drivers.router registered in main.py - drivers.html template with HTMX upload form - partials/driver_list.html HTMX target with select dropdown and unused-file notice - Fixed conftest client fixture to use context manager (triggers lifespan/init_db) - [Rule 3] conftest: TestClient context manager required for lifespan trigger - [Rule 1] drivers.py: dynamic DRIVERS_DIR read so monkeypatch works in tests
28 lines
666 B
Python
28 lines
666 B
Python
import os
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture
|
|
def client(tmp_data_dir):
|
|
from imptune.main import app
|
|
|
|
with TestClient(app) as c:
|
|
yield c
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_data_dir(tmp_path, monkeypatch):
|
|
"""Set DATA_DIR to a temp directory so tests don't write to /data."""
|
|
data_dir = tmp_path / "data"
|
|
data_dir.mkdir()
|
|
monkeypatch.setenv("DATA_DIR", str(data_dir))
|
|
# Patch config module so the app uses the temp dir
|
|
import imptune.config as cfg
|
|
|
|
cfg.DATA_DIR = str(data_dir)
|
|
cfg.DB_PATH = str(data_dir / "imptune.db")
|
|
cfg.DRIVERS_DIR = str(data_dir / "drivers")
|
|
return data_dir
|