def test_normal_lock_codes(mocker) -> None: hub = mocker.MagicMock() device = mocker.MagicMock() device.attributes = { hm.ATTR_LOCK_CODES: hm.Attribute({ "name": hm.ATTR_LOCK_CODES, "currentValue": '{"1":{"name":"Test","code":"1234"}}', }) } from custom_components.hubitat.lock import HubitatLock lock = HubitatLock(hub=hub, device=device) assert isinstance(lock.codes, dict)
def test_encrypted_lock_codes(mocker) -> None: hub = mocker.MagicMock() device = mocker.MagicMock() device.attributes = { hm.ATTR_LOCK_CODES: hm.Attribute({ "name": hm.ATTR_LOCK_CODES, "currentValue": "abc1235Qbxyz" }) } from custom_components.hubitat.lock import HubitatLock lock = HubitatLock(hub=hub, device=device) # A lock with encrypted codes should return a string for the `codes` # property assert isinstance(lock.codes, str)
def test_normal_lock_codes() -> None: hub = Mock() hub.configure_mock(token="abc1235Qbxyz") device = Mock() device.configure_mock( attributes={ ATTR_LOCK_CODES: Attribute({ "name": ATTR_LOCK_CODES, "currentValue": '{"1":{"name":"Test","code":"1234"}}', }) }) from custom_components.hubitat.lock import HubitatLock lock = HubitatLock(hub=hub, device=device) codes = lock.codes assert isinstance(codes, dict) assert codes["1"].get("name") == "Test" assert codes["1"].get("code") is None
def test_encrypted_lock_codes() -> None: hub = Mock() hub.configure_mock(token="abc1235Qbxyz") device = Mock() device.configure_mock( attributes={ ATTR_LOCK_CODES: Attribute({ "name": ATTR_LOCK_CODES, "currentValue": "abc1235Qbxyz" }) }) from custom_components.hubitat.lock import HubitatLock lock = HubitatLock(hub=hub, device=device) # A lock with encrypted codes should return a string for the `codes` # property assert isinstance(lock.codes, str)