fix: replace IP-named dumps with scrubbed named fixtures

Rename tests/fixtures/dumps/{IP}.json to tests/fixtures/{name}_device.json.
Scrub PII: serialNum, otnDUID, modelNum, diagEndPoint replaced with
TEST-* placeholders. conftest: _load_device(name) as primary API;
_load_resources(ip) kept as legacy shim for existing test call sites.
This commit is contained in:
Marc Billow
2026-06-30 16:33:36 -05:00
parent 27d6d09fd9
commit fd2aa9e64d
2 changed files with 23 additions and 14 deletions
+17 -5
View File
@@ -3,7 +3,7 @@ from pathlib import Path
import pytest
DUMPS = Path(__file__).resolve().parent / 'fixtures' / 'dumps'
FIXTURES = Path(__file__).resolve().parent / 'fixtures'
def _resources_from_dump(dump: dict) -> dict[str, dict]:
@@ -17,16 +17,28 @@ def _resources_from_dump(dump: dict) -> dict[str, dict]:
if isinstance(v, dict)}
def _load_resources(ip: str) -> dict[str, dict]:
data = json.loads((DUMPS / f'{ip}.json').read_text())
def _load_device(name: str) -> dict[str, dict]:
data = json.loads((FIXTURES / f'{name}_device.json').read_text())
return _resources_from_dump(data)
def _load_resources(ip: str) -> dict[str, dict]:
"""Legacy IP-based loader — maps known IPs to named fixtures."""
_ip_to_name = {
'10.0.0.129': 'dishwasher',
'10.0.0.254': 'refrigerator',
}
name = _ip_to_name.get(ip)
if name is None:
raise ValueError(f"No fixture for IP {ip!r} — add a scrubbed fixture to tests/fixtures/")
return _load_device(name)
@pytest.fixture
def dishwasher_resources() -> dict[str, dict]:
return _load_resources('10.0.0.129')
return _load_device('dishwasher')
@pytest.fixture
def fridge_resources() -> dict[str, dict]:
return _load_resources('10.0.0.254')
return _load_device('refrigerator')
+6 -9
View File
@@ -1,19 +1,16 @@
import json
import pytest
from tests.conftest import _resources_from_dump
from tests.conftest import _load_device
from samsung_appliance.registry.by_type import for_device, _type_key
from samsung_appliance.registry.discovery import discover
from samsung_appliance.registry.adapter import build_runtime_descriptor
@pytest.mark.parametrize('name,ip,expected_type_key', [
('dishwasher', '10.0.0.129', 'dishwasher'),
('refrigerator', '10.0.0.254', 'refrigerator'),
@pytest.mark.parametrize('name,expected_type_key', [
('dishwasher', 'dishwasher'),
('refrigerator', 'refrigerator'),
])
def test_full_pipeline_v2(name, ip, expected_type_key):
with open(f'tests/fixtures/dumps/{ip}.json') as f:
dump = json.load(f)
resources = _resources_from_dump(dump)
def test_full_pipeline_v2(name, expected_type_key):
resources = _load_device(name)
otn = resources.get('/otninformation/vs/0', {})
one_ui = otn.get('swVersionInfo', {}).get('oneUiVersion', '')