示例#1
0
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)
示例#2
0
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)
示例#3
0
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
示例#4
0
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)