--- phase: 02-driver-management plan: "02" subsystem: api tags: [fastapi, htmx, jinja2, peewee, zipfile, sha256, dedup, inf-parser] # Dependency graph requires: - phase: 02-01 provides: INF parser service (parse_inf, ParsedInf, _detect_encoding) - phase: 01-foundation provides: FastAPI app shell, DriverStore, Driver model, init_db, base templates provides: - POST /drivers/upload endpoint with ZIP validation, INF parsing, SHA256 dedup, Peewee persistence - GET /drivers page with HTMX upload form and driver library table - HTMX partial (partials/driver_list.html) returned on upload with select dropdown and unused-file notice - Integration test suite (8 tests) for driver upload flow affects: [03-printer-management, 04-package-generation] # Tech tracking tech-stack: added: [] patterns: - HTMX outerHTML swap: upload endpoint returns partial HTML fragment replacing #driver-list div - Dynamic config read: import imptune.config as _cfg and read _cfg.DRIVERS_DIR at call time for monkeypatch compatibility - TDD workflow: RED (test commit) -> GREEN (impl commit) within same task key-files: created: - imptune/api/drivers.py - imptune/templates/drivers.html - imptune/templates/partials/driver_list.html - tests/test_driver_upload.py modified: - imptune/api/pages.py - imptune/main.py - tests/conftest.py key-decisions: - "Always render ` dropdown - 8 integration tests written TDD-first (RED commit, then GREEN): page render, valid upload, non-ZIP 400, no-INF 400, select presence, DB persistence, dedup, unused files in response ## Task Commits 1. **Test RED phase: failing integration tests** - `8ecfbf2` (test) 2. **Task 1 + Task 2: upload endpoint, templates, pages route, router registration** - `c648fc5` (feat) ## Files Created/Modified - `imptune/api/drivers.py` - POST /drivers/upload endpoint with full validation, INF parsing, DriverStore save, Peewee get_or_create - `imptune/api/pages.py` - Added GET /drivers route with driver_data context - `imptune/main.py` - Registered drivers.router - `imptune/templates/drivers.html` - Drivers page extending base.html with HTMX upload form - `imptune/templates/partials/driver_list.html` - HTMX swap target with table, select dropdown, unused-files notice - `tests/test_driver_upload.py` - 8 integration tests covering all success and error paths - `tests/conftest.py` - Fixed client fixture to use TestClient as context manager ## Decisions Made - Always render `` for any non-empty names list** - **Found during:** Task 1 GREEN (test_upload_returns_select failure) - **Issue:** Template only showed `