Files
app/backend/tests/flow/conftest.py
T
Melvin Strobl a7a18bf19f
Docs / docs (push) Successful in 25s
Playwright Tests / test-playwright (1, 2) (push) Failing after 2m52s
Playwright Tests / test-playwright (2, 2) (push) Failing after 21s
pre-commit / pre-commit (push) Failing after 2m28s
Test Backend / test-backend (3.12) (push) Failing after 5m8s
Test Backend / test-backend (3.14) (push) Failing after 4m38s
Compose Smoke Test / test-compose (push) Failing after 25s
Playwright Tests / merge-reports (push) Failing after 2m24s
wren applies all/every commands itself, answers temperatures, reads aliases and number words; tts says units and clock times
wren's model answers "turn off all lights" with one call, and at 0.98 a
living room light switched on. The node now applies such a command to every
wired target of the kind. Number words become digits ("in five minutes"
lost its delay), aliases put the house's words and known mishearings in the
model's, and sensors.temperature is answered from <area>_temperature or
outdoor. tts writes out units and clock times before speaking.
2026-10-22 12:34:40 +02:00

58 lines
1.4 KiB
Python

from collections.abc import Generator
from dataclasses import dataclass
from typing import Any
import pytest
@pytest.fixture(scope="session", autouse=True)
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] = []
self.commands: list[str] = []
def act(self, command: str, house: _House) -> tuple[list[Any], float]:
self.houses.append(house)
self.commands.append(command)
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