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.
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import cbor2
|
|
|
|
from custom_components.localthings.registry.identity import DeviceIdentity, read_identity
|
|
|
|
|
|
class FakeSession:
|
|
def __init__(self, table):
|
|
self.table = table # tuple(path) -> rep dict
|
|
|
|
def get(self, path, timeout=10.0):
|
|
rep = self.table.get(tuple(path))
|
|
if rep is None:
|
|
return 0x84, b'' # 4.04 not found
|
|
return 0x45, cbor2.dumps(rep)
|
|
|
|
|
|
def test_read_identity_from_oic_p_and_d():
|
|
sess = FakeSession({
|
|
('oic', 'p'): {'mnmn': 'Samsung Electronics', 'mnmo': 'RF9000B'},
|
|
('oic', 'd'): {'n': 'Family Hub'},
|
|
})
|
|
ident = read_identity(sess, serial='ABC123')
|
|
assert ident.manufacturer == 'Samsung Electronics'
|
|
assert ident.model == 'RF9000B'
|
|
assert ident.name == 'Family Hub'
|
|
assert ident.serial == 'ABC123'
|
|
|
|
|
|
def test_read_identity_tolerates_missing_resources():
|
|
ident = read_identity(FakeSession({}), serial=None)
|
|
assert ident.manufacturer == 'Samsung'
|
|
assert ident.model == ''
|
|
assert ident.serial is None
|