Files
localthings/tests/conftest.py
T
Marc Billow d4ff29d797 feat: switch conftest + golden tests to batch-first resource loading
conftest: _resources_from_dump() prefers /device/0 batch reps; falls
back to flat resources dict. Fixes _parse_device0_batch to include
stub reps (rep={href:...}) as {} so capabilities still bind on
resources with no current data (e.g. /alarms/vs/0 when no alarm active).

test_golden_regression: _new_state_and_uids now uses by_type.for_device
to select per-device-type capabilities + pattern caps.
2026-06-30 16:33:36 -05:00

33 lines
859 B
Python

import json
from pathlib import Path
import pytest
DUMPS = Path(__file__).resolve().parent.parent / 'local-tools' / 'dumps'
def _resources_from_dump(dump: dict) -> dict[str, dict]:
from samsung_appliance.bridge import _parse_device0_batch
d0 = dump.get('device0')
if isinstance(d0, list) and len(d0) > 1:
batch = _parse_device0_batch(d0)
if batch:
return batch
return {k: v for k, v in dump.get('resources', {}).items()
if isinstance(v, dict)}
def _load_resources(ip: str) -> dict[str, dict]:
data = json.loads((DUMPS / f'{ip}.json').read_text())
return _resources_from_dump(data)
@pytest.fixture
def dishwasher_resources() -> dict[str, dict]:
return _load_resources('10.0.0.129')
@pytest.fixture
def fridge_resources() -> dict[str, dict]:
return _load_resources('10.0.0.254')