Files
localthings/tests/conftest.py
T
Marc Billow 27d6d09fd9 refactor: auto-derive pattern cap keys from href; move dumps to tests/fixtures
Remove key_fn from Capability — pattern cap keys are now always derived
automatically: strip digits from href segments, join with '_', append
'_' + desc.key. /door/cooler/0 + 'open' -> door_cooler_open.

DOOR_GENERIC entity key: 'open' (not 'door_open'). Remove _door_key helper.
Fridge registry: DOOR_FRIDGE/DOOR_FREEZER replaced by DOOR_GENERIC pattern cap.
Golden baseline: door_fridge_open -> door_cooler_open.

Move device dumps to tests/fixtures/dumps/ (tracked) so tests run in CI
without local-tools/ dependencies.
2026-06-30 16:33:36 -05:00

33 lines
849 B
Python

import json
from pathlib import Path
import pytest
DUMPS = Path(__file__).resolve().parent / 'fixtures' / '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')