feat: read device identity from OCF /oic/p and /oic/d
This commit is contained in:
1 parent
246379acbc
commit
f2c1d8391e
2 files changed
+70
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import cbor2
|
||||
|
||||
from samsung_appliance.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
|
||||
Reference in new issue
Block a user