Rename ocf/ to registry/, it's a capability registry now
The DTLS/CoAP transport code that made "ocf" an accurate name moved out to the smartthings-local package. What's left here (capability.py, entities.py, discovery.py, adapter.py, identity.py, capabilities/, by_type/, plus the /device/0 batch parser) is entirely the device capability registry, so name the package for what it does. Flattened the redundant ocf/registry/ nesting into a single top-level registry/ package and updated every import across the platform modules and test suite accordingly. Verified: full test suite (80/80) passes, and the Docker dev container reconnects to both live appliances and rediscovers their entities cleanly after the rename.
This commit is contained in:
1 parent
3502a385cc
commit
b67e0e5cf5
51 files changed
+72
-70
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ FIXTURES = Path(__file__).resolve().parent / 'fixtures'
|
||||
|
||||
|
||||
def _resources_from_dump(dump: dict) -> dict[str, dict]:
|
||||
from custom_components.localthings.ocf.batch import parse_device0_batch
|
||||
from custom_components.localthings.registry.batch import parse_device0_batch
|
||||
return parse_device0_batch(dump['device0'])
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ ENTRY_DATA = {
|
||||
|
||||
|
||||
def _load_fridge_resources() -> dict:
|
||||
from custom_components.localthings.ocf.batch import parse_device0_batch
|
||||
from custom_components.localthings.registry.batch import parse_device0_batch
|
||||
data = json.loads((FIXTURES / 'refrigerator_device.json').read_text())
|
||||
return parse_device0_batch(data['device0'])
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for samsung_appliance/registry/by_type."""
|
||||
import pytest
|
||||
from custom_components.localthings.ocf.registry.by_type import _type_key, for_device, DeviceRegistry
|
||||
from custom_components.localthings.registry.by_type import _type_key, for_device, DeviceRegistry
|
||||
|
||||
|
||||
class TestTypeKey:
|
||||
|
||||
@@ -4,10 +4,10 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from custom_components.localthings.ocf.registry.adapter import _key
|
||||
from custom_components.localthings.ocf.registry.by_type import dishwasher, refrigerator
|
||||
from custom_components.localthings.ocf.registry.capabilities import fridge
|
||||
from custom_components.localthings.ocf.registry.discovery import discover
|
||||
from custom_components.localthings.registry.adapter import _key
|
||||
from custom_components.localthings.registry.by_type import dishwasher, refrigerator
|
||||
from custom_components.localthings.registry.capabilities import fridge
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
from tests.conftest import _load_resources
|
||||
|
||||
GOLDEN = Path(__file__).parent / 'fixtures' / 'golden'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from custom_components.localthings.ocf.registry.capability import Capability
|
||||
from custom_components.localthings.ocf.registry.entities import BinarySensorDesc
|
||||
from custom_components.localthings.registry.capability import Capability
|
||||
from custom_components.localthings.registry.entities import BinarySensorDesc
|
||||
|
||||
|
||||
def test_capability_defaults():
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from custom_components.localthings.ocf.registry.capabilities import common
|
||||
from custom_components.localthings.ocf.registry.discovery import discover
|
||||
from custom_components.localthings.registry.capabilities import common
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
|
||||
|
||||
def _reg():
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from custom_components.localthings.ocf.registry.capability import Capability
|
||||
from custom_components.localthings.ocf.registry.discovery import (
|
||||
from custom_components.localthings.registry.capability import Capability
|
||||
from custom_components.localthings.registry.discovery import (
|
||||
BoundEntity, discover, instance_suffix,
|
||||
)
|
||||
from custom_components.localthings.ocf.registry.entities import BinarySensorDesc
|
||||
from custom_components.localthings.registry.entities import BinarySensorDesc
|
||||
|
||||
LOCK = Capability(
|
||||
href='/kidslock/vs/0',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import pytest
|
||||
from tests.conftest import _load_device
|
||||
from custom_components.localthings.ocf.registry.by_type import for_device, _type_key
|
||||
from custom_components.localthings.ocf.registry.discovery import discover
|
||||
from custom_components.localthings.ocf.registry.adapter import flatten, is_active
|
||||
from custom_components.localthings.registry.by_type import for_device, _type_key
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
from custom_components.localthings.registry.adapter import flatten, is_active
|
||||
|
||||
|
||||
@pytest.mark.parametrize('name,expected_type_key', [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from custom_components.localthings.ocf.registry.entities import (
|
||||
from custom_components.localthings.registry.entities import (
|
||||
SensorDesc, BinarySensorDesc, SelectDesc, SwitchDesc, ButtonDesc,
|
||||
NumberDesc, PLATFORM_OF,
|
||||
)
|
||||
|
||||
@@ -7,9 +7,9 @@ pattern capability that auto-derives distinct keys from the href segments.
|
||||
"""
|
||||
from tests.conftest import _load_resources
|
||||
|
||||
from custom_components.localthings.ocf.registry.adapter import _key
|
||||
from custom_components.localthings.ocf.registry.by_type import refrigerator
|
||||
from custom_components.localthings.ocf.registry.discovery import discover
|
||||
from custom_components.localthings.registry.adapter import _key
|
||||
from custom_components.localthings.registry.by_type import refrigerator
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
|
||||
|
||||
def test_two_doors_get_distinct_keys():
|
||||
|
||||
@@ -7,14 +7,14 @@ GOLDEN = Path(__file__).parent / 'fixtures' / 'golden'
|
||||
|
||||
|
||||
def _new_state_keys(name, resources):
|
||||
from custom_components.localthings.ocf.registry.by_type import for_device
|
||||
from custom_components.localthings.ocf.registry.discovery import discover
|
||||
from custom_components.localthings.ocf.registry.adapter import flatten
|
||||
from custom_components.localthings.registry.by_type import for_device
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
from custom_components.localthings.registry.adapter import flatten
|
||||
otn = resources.get('/otninformation/vs/0', {})
|
||||
one_ui = otn.get('swVersionInfo', {}).get('oneUiVersion', '')
|
||||
reg = for_device(one_ui) if one_ui else None
|
||||
if reg is None:
|
||||
from custom_components.localthings.ocf.registry.registry import CAPABILITIES
|
||||
from custom_components.localthings.registry.registry import CAPABILITIES
|
||||
caps, pats = CAPABILITIES, []
|
||||
else:
|
||||
caps, pats = reg.capabilities, reg.pattern_capabilities
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import cbor2
|
||||
|
||||
from custom_components.localthings.ocf.registry.identity import DeviceIdentity, read_identity
|
||||
from custom_components.localthings.registry.identity import DeviceIdentity, read_identity
|
||||
|
||||
|
||||
class FakeSession:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Write-handler unit tests for laundry-family capabilities."""
|
||||
from custom_components.localthings.ocf.registry.capabilities import laundry
|
||||
from custom_components.localthings.ocf.registry.capabilities.operational import OPERATIONAL_STATE
|
||||
from custom_components.localthings.registry.capabilities import laundry
|
||||
from custom_components.localthings.registry.capabilities.operational import OPERATIONAL_STATE
|
||||
|
||||
|
||||
def test_start_button_writes_run():
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from custom_components.localthings.ocf.registry.capabilities.operational import OPERATIONAL_STATE
|
||||
from custom_components.localthings.registry.capabilities.operational import OPERATIONAL_STATE
|
||||
|
||||
|
||||
def test_machine_state_maps_samsung_to_ocf():
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Unit tests for oven-family capabilities."""
|
||||
from custom_components.localthings.ocf.registry.capabilities import oven
|
||||
from custom_components.localthings.ocf.registry.discovery import discover
|
||||
from custom_components.localthings.registry.capabilities import oven
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Tests for the CAPABILITIES registry."""
|
||||
from custom_components.localthings.ocf.registry.registry import CAPABILITIES
|
||||
from custom_components.localthings.registry.registry import CAPABILITIES
|
||||
|
||||
|
||||
def test_registry_is_keyed_by_href():
|
||||
|
||||
Reference in new issue
Block a user