Begins the lift of `web_server._register_automation_handlers` (1530 lines, 20 nested closures) into `core/automation/handlers/`. Each extracted handler is a top-level function that accepts `(config, deps)` instead of reaching for module-level globals -- makes them unit-testable in isolation. Infrastructure: - `core/automation/deps.py`: `AutomationDeps` (dependency-injection bundle of clients + callables) and `AutomationState` (mutable flags shared across handler invocations, with thread-safe accessors). - `core/automation/handlers/__init__.py` + `registration.py`: one-stop `register_all(deps)` that wires every extracted handler to the engine. First batch of handlers extracted: - `process_wishlist` -> `core/automation/handlers/process_wishlist.py` - `scan_watchlist` -> `core/automation/handlers/scan_watchlist.py` - `scan_library` -> `core/automation/handlers/scan_library.py` `web_server._register_automation_handlers` now builds the deps once and calls `register_all(deps)` for the extracted batch. Remaining 17 closures still live below; subsequent commits in this branch finish the lift. 14 boundary tests in `tests/automation/test_handlers_simple.py` pin every shape: success path, exception swallow contract, fresh-vs-stale state detection (scan_watchlist's id() trick), guard short-circuits, state cleanup on exceptions, AutomationState concurrent-safe accessors. All 101 automation tests pass; no regression.
11 lines
473 B
Python
11 lines
473 B
Python
"""Automation API + progress + handlers package.
|
|
|
|
Lifted from web_server.py:
|
|
- `/api/automations/*` route helpers → `api.py`
|
|
- block library used by the trigger/action UI → `blocks.py`
|
|
- progress tracker (init / update / finish) → `progress.py`
|
|
- cross-handler signal bus → `signals.py`
|
|
- per-action handler functions → `handlers/` subpackage (with
|
|
`deps.py` defining the dependency-injection surface so handlers
|
|
stay testable in isolation)
|
|
"""
|