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.
23 lines
797 B
Python
23 lines
797 B
Python
"""Per-action automation handlers.
|
|
|
|
Each module in this subpackage exposes one top-level handler function
|
|
(or a small cluster of related handlers) of the form::
|
|
|
|
def auto_<action_name>(config: dict, deps: AutomationDeps) -> dict
|
|
|
|
The ``register_all`` helper in :mod:`registration` wires every handler
|
|
to the engine in one place. ``web_server.py`` calls
|
|
``register_all(deps)`` once at startup.
|
|
"""
|
|
|
|
from core.automation.handlers.process_wishlist import auto_process_wishlist
|
|
from core.automation.handlers.scan_watchlist import auto_scan_watchlist
|
|
from core.automation.handlers.scan_library import auto_scan_library
|
|
from core.automation.handlers.registration import register_all
|
|
|
|
__all__ = [
|
|
'auto_process_wishlist',
|
|
'auto_scan_watchlist',
|
|
'auto_scan_library',
|
|
'register_all',
|
|
]
|