Add the wren node: a typed command into values for the devices wired to it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-05 20:58:59 +02:00
co-authored by Claude Opus 5.5
parent 550185b73c
commit d8edce55f9
8 changed files with 561 additions and 2 deletions
+46
View File
@@ -1,4 +1,6 @@
from collections.abc import Generator
from dataclasses import dataclass
from typing import Any
import pytest
@@ -7,3 +9,47 @@ import pytest
def db() -> Generator[None, None, None]:
"""The engine holds no database state, so these tests need no database."""
yield
@dataclass
class _Device:
kind: str
id: str
state: str
@dataclass
class _House:
time: str
outdoor_c: float
dark: bool
user_area: str | None
areas: dict[str, list[_Device]]
class FakeWren:
"""The model package's surface, answering whatever a test sets ``answer`` to."""
AREAS = [
*("living room", "kitchen", "bathroom", "bedroom", "office"),
*("garden", "patio", "garage", "driveway", "balcony"),
]
KINDS = ["light", "media", "heat", "shutter", "water"]
Device = _Device
House = _House
def __init__(self) -> None:
self.answer: tuple[list[Any], float] = ([], 1.0)
self.houses: list[_House] = []
def act(self, command: str, house: _House) -> tuple[list[Any], float]:
self.houses.append(house)
return self.answer
@pytest.fixture
def fake_wren(monkeypatch: pytest.MonkeyPatch) -> FakeWren:
"""Stands in for the optional model package the wren node imports."""
fake = FakeWren()
monkeypatch.setattr("fluksio.flow.nodes.wren._wren", lambda: fake)
return fake