utec-client 0.5.2__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {utec_client-0.5.2/src/utec_client.egg-info → utec_client-0.5.4}/PKG-INFO +5 -1
- {utec_client-0.5.2 → utec_client-0.5.4}/README.md +4 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/device_const.py +14 -1
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/lock.py +29 -8
- {utec_client-0.5.2 → utec_client-0.5.4/src/utec_client.egg-info}/PKG-INFO +5 -1
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client.egg-info/SOURCES.txt +1 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client.egg-info/scm_file_list.json +1 -0
- utec_client-0.5.4/src/utec_client.egg-info/scm_version.json +8 -0
- utec_client-0.5.4/tests/test_door_state.py +105 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_lock.py +66 -0
- utec_client-0.5.2/src/utec_client.egg-info/scm_version.json +0 -8
- {utec_client-0.5.2 → utec_client-0.5.4}/.github/dependabot.yml +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.github/workflows/manual-release.yml +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.github/workflows/publish.yml +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.github/workflows/test.yml +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.github/workflows/weekly-release.yml +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.gitignore +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.vscode/launch.json +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/.vscode/settings.json +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/LICENSE +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/MIGRATION.md +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/pyproject.toml +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/check_artifact.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/find_validated_build.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/prepare_release.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/pypi_preflight.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/release_logic.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/test_api_behavior.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/test_webhook.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/verify_assets.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/scripts/verify_validated_build.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/setup.cfg +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/__init__.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/api.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/auth.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/const.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/__init__.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/device.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/light.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/sensor.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/devices/switch.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client/exceptions.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client.egg-info/dependency_links.txt +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client.egg-info/requires.txt +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/src/utec_client.egg-info/top_level.txt +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/__init__.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/conftest.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_api.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_auth.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_base_device.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_device_const.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_device_info.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_exceptions.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_light.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_publish_pipeline.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_pypi_discovery_boundary.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_pypi_readback_retries.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_release_discovery.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_release_logic.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_release_plumbing.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_response_release.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_smoke.py +0 -0
- {utec_client-0.5.2 → utec_client-0.5.4}/tests/test_switch.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: utec-client
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: An independently maintained U-Tec/U-Home API client library.
|
|
5
5
|
Author-email: Luke Wallis <wallis.luke4@gmail.com>
|
|
6
6
|
Maintainer: Geoff Franks
|
|
@@ -81,6 +81,10 @@ Device info is organized with minimal change from the raw API response
|
|
|
81
81
|
integration downstream. Locks are the most fully supported device type;
|
|
82
82
|
switches and lights have limited functionality.
|
|
83
83
|
|
|
84
|
+
Lock door sensors accept both `doorState` (including U-Bolt-Pro-WiFi payloads)
|
|
85
|
+
and legacy `sensorState` attributes under `st.DoorSensor` or `st.doorSensor`.
|
|
86
|
+
When both attributes supply nonempty values, `doorState` takes precedence.
|
|
87
|
+
|
|
84
88
|
## Development
|
|
85
89
|
|
|
86
90
|
Requires Python 3.11–3.14.
|
|
@@ -48,6 +48,10 @@ Device info is organized with minimal change from the raw API response
|
|
|
48
48
|
integration downstream. Locks are the most fully supported device type;
|
|
49
49
|
switches and lights have limited functionality.
|
|
50
50
|
|
|
51
|
+
Lock door sensors accept both `doorState` (including U-Bolt-Pro-WiFi payloads)
|
|
52
|
+
and legacy `sensorState` attributes under `st.DoorSensor` or `st.doorSensor`.
|
|
53
|
+
When both attributes supply nonempty values, `doorState` takes precedence.
|
|
54
|
+
|
|
51
55
|
## Development
|
|
52
56
|
|
|
53
57
|
Requires Python 3.11–3.14.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"""Device types and constants for U-Home API devices."""
|
|
2
2
|
|
|
3
|
+
from collections.abc import Mapping
|
|
3
4
|
from dataclasses import dataclass
|
|
4
5
|
from enum import Enum, IntEnum
|
|
6
|
+
from types import MappingProxyType
|
|
5
7
|
from typing import Any
|
|
6
8
|
|
|
7
9
|
|
|
@@ -60,8 +62,19 @@ class LockMode(IntEnum):
|
|
|
60
62
|
LOCKED = 2
|
|
61
63
|
|
|
62
64
|
|
|
65
|
+
# Label for each LockMode, as returned by Lock.lock_mode. Read-only because
|
|
66
|
+
# every Lock shares it.
|
|
67
|
+
LOCK_MODE_LABELS: Mapping[LockMode, str] = MappingProxyType(
|
|
68
|
+
{
|
|
69
|
+
LockMode.NORMAL: "Normal",
|
|
70
|
+
LockMode.PASSAGE: "Passage",
|
|
71
|
+
LockMode.LOCKED: "Locked",
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
63
76
|
class DoorState(str, Enum):
|
|
64
|
-
"""Door state values from API
|
|
77
|
+
"""Door state values from API doorState or legacy sensorState attributes."""
|
|
65
78
|
|
|
66
79
|
CLOSED = "Closed"
|
|
67
80
|
OPEN = "Open"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from .device import BaseDevice
|
|
4
4
|
from .device_const import (
|
|
5
|
+
LOCK_MODE_LABELS,
|
|
5
6
|
DeviceCapability,
|
|
6
7
|
DeviceCategory,
|
|
7
8
|
DeviceCommand,
|
|
@@ -42,19 +43,19 @@ class Lock(BaseDevice):
|
|
|
42
43
|
"""Get the door state if door sensor is present."""
|
|
43
44
|
if not self.has_door_sensor:
|
|
44
45
|
return None
|
|
45
|
-
|
|
46
|
-
return
|
|
46
|
+
# Prefer doorState across capability spellings, retaining legacy falsey fallback.
|
|
47
|
+
return (
|
|
48
|
+
self._get_state_value(DeviceCapability.DOOR_SENSOR, "doorState")
|
|
49
|
+
or self._get_state_value("st.doorSensor", "doorState")
|
|
50
|
+
or self._get_state_value(DeviceCapability.DOOR_SENSOR, "sensorState")
|
|
51
|
+
or self._get_state_value("st.doorSensor", "sensorState")
|
|
52
|
+
)
|
|
47
53
|
|
|
48
54
|
@property
|
|
49
55
|
def lock_mode(self) -> str | None:
|
|
50
56
|
"""Get the current lock mode."""
|
|
51
57
|
state = self._get_state_value(DeviceCapability.LOCK, "lockMode")
|
|
52
|
-
|
|
53
|
-
LockMode.NORMAL: "Normal",
|
|
54
|
-
LockMode.PASSAGE: "Passage",
|
|
55
|
-
LockMode.LOCKED: "Locked",
|
|
56
|
-
}
|
|
57
|
-
return lock_mode_map.get(state)
|
|
58
|
+
return LOCK_MODE_LABELS.get(state)
|
|
58
59
|
|
|
59
60
|
@property
|
|
60
61
|
def is_locked(self) -> bool:
|
|
@@ -106,3 +107,23 @@ class Lock(BaseDevice):
|
|
|
106
107
|
"""Unlock the device."""
|
|
107
108
|
command = DeviceCommand(capability=DeviceCapability.LOCK, name="unlock")
|
|
108
109
|
await self.send_command(command)
|
|
110
|
+
|
|
111
|
+
async def set_mode(self, mode: LockMode) -> None:
|
|
112
|
+
"""Set the lock's working mode (Normal, Passage or Locked).
|
|
113
|
+
|
|
114
|
+
Sends the OpenAPI st.lock command setMode with arguments {"mode": 0|1|2}.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
ValueError: If mode is not a LockMode member. Plain ints, bools
|
|
118
|
+
and floats are rejected even when they equal a valid mode.
|
|
119
|
+
DeviceError: If sending the command fails.
|
|
120
|
+
|
|
121
|
+
"""
|
|
122
|
+
if not isinstance(mode, LockMode):
|
|
123
|
+
raise ValueError(f"mode must be a LockMode member, got {mode!r}")
|
|
124
|
+
command = DeviceCommand(
|
|
125
|
+
capability=DeviceCapability.LOCK,
|
|
126
|
+
name="setMode",
|
|
127
|
+
arguments={"mode": int(mode)},
|
|
128
|
+
)
|
|
129
|
+
await self.send_command(command)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: utec-client
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: An independently maintained U-Tec/U-Home API client library.
|
|
5
5
|
Author-email: Luke Wallis <wallis.luke4@gmail.com>
|
|
6
6
|
Maintainer: Geoff Franks
|
|
@@ -81,6 +81,10 @@ Device info is organized with minimal change from the raw API response
|
|
|
81
81
|
integration downstream. Locks are the most fully supported device type;
|
|
82
82
|
switches and lights have limited functionality.
|
|
83
83
|
|
|
84
|
+
Lock door sensors accept both `doorState` (including U-Bolt-Pro-WiFi payloads)
|
|
85
|
+
and legacy `sensorState` attributes under `st.DoorSensor` or `st.doorSensor`.
|
|
86
|
+
When both attributes supply nonempty values, `doorState` takes precedence.
|
|
87
|
+
|
|
84
88
|
## Development
|
|
85
89
|
|
|
86
90
|
Requires Python 3.11–3.14.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Door-state attribute compatibility across Query and push snapshots."""
|
|
2
|
+
|
|
3
|
+
from itertools import combinations
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from utec_client.devices.lock import Lock
|
|
8
|
+
|
|
9
|
+
# Ordered by attribute preference first, then capability spelling.
|
|
10
|
+
ALIASES = (
|
|
11
|
+
("st.DoorSensor", "doorState"),
|
|
12
|
+
("st.doorSensor", "doorState"),
|
|
13
|
+
("st.DoorSensor", "sensorState"),
|
|
14
|
+
("st.doorSensor", "sensorState"),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def state(alias, value):
|
|
19
|
+
return {"capability": alias[0], "name": alias[1], "value": value}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture(params=["utec-lock", "utec-lock-sensor"])
|
|
23
|
+
def lock(request, discovery_dict, mock_api):
|
|
24
|
+
return Lock(discovery_dict(handle_type=request.param, category="SmartLock"), mock_api)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.parametrize("alias", ALIASES)
|
|
28
|
+
@pytest.mark.parametrize("value", ["Open", "Closed", "Unrecognized"])
|
|
29
|
+
def test_attribute_values_and_sensor_detection(lock, alias, value):
|
|
30
|
+
lock._state_data = {"states": [state(alias, value)]}
|
|
31
|
+
assert lock.has_door_sensor is True
|
|
32
|
+
assert lock.door_state == value
|
|
33
|
+
assert lock.is_door_open is (value == "Open")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.parametrize("preferred, fallback", list(combinations(ALIASES, 2)))
|
|
37
|
+
@pytest.mark.parametrize("reverse", [False, True])
|
|
38
|
+
@pytest.mark.parametrize("value", ["Open", "Closed", "Unrecognized"])
|
|
39
|
+
def test_alias_precedence_ignores_payload_order(lock, preferred, fallback, reverse, value):
|
|
40
|
+
states = [state(preferred, value), state(fallback, "Closed" if value == "Open" else "Open")]
|
|
41
|
+
lock._state_data = {"states": states[::-1] if reverse else states}
|
|
42
|
+
assert lock.door_state == value
|
|
43
|
+
assert lock.is_door_open is (value == "Open")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.parametrize("winner", range(len(ALIASES)))
|
|
47
|
+
@pytest.mark.parametrize("falsey", [None, "", 0, False])
|
|
48
|
+
@pytest.mark.parametrize("missing_value", [False, True])
|
|
49
|
+
def test_falsey_preferred_aliases_fall_through(lock, winner, falsey, missing_value):
|
|
50
|
+
states = [state(alias, falsey) for alias in ALIASES[:winner]]
|
|
51
|
+
if missing_value:
|
|
52
|
+
for entry in states:
|
|
53
|
+
del entry["value"]
|
|
54
|
+
states.append(state(ALIASES[winner], "Open"))
|
|
55
|
+
lock._state_data = {"states": states}
|
|
56
|
+
assert lock.door_state == "Open"
|
|
57
|
+
assert lock.is_door_open is True
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@pytest.mark.parametrize("alias", ALIASES)
|
|
61
|
+
@pytest.mark.parametrize("value", [None, "", 0, False])
|
|
62
|
+
def test_falsey_only_preserves_final_lookup_return(lock, alias, value):
|
|
63
|
+
lock._state_data = {"states": [state(alias, value)]}
|
|
64
|
+
expected = value if alias == ALIASES[-1] else None
|
|
65
|
+
assert lock.has_door_sensor is True
|
|
66
|
+
assert lock.door_state is expected
|
|
67
|
+
assert lock.is_door_open is False
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@pytest.mark.parametrize("snapshot", [None, {}, {"states": []}])
|
|
71
|
+
def test_no_sensor_state_preserves_discovery_semantics(lock, snapshot):
|
|
72
|
+
lock._state_data = snapshot
|
|
73
|
+
assert lock.door_state is None
|
|
74
|
+
assert lock.is_door_open is (False if lock.has_door_sensor else None)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@pytest.mark.parametrize("alias", ALIASES)
|
|
78
|
+
def test_sensor_entry_without_value(lock, alias):
|
|
79
|
+
lock._state_data = {"states": [{"capability": alias[0], "name": alias[1]}]}
|
|
80
|
+
assert lock.has_door_sensor is True
|
|
81
|
+
assert lock.door_state is None
|
|
82
|
+
assert lock.is_door_open is False
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@pytest.mark.parametrize("alias", ALIASES)
|
|
86
|
+
def test_duplicate_pair_retains_first_lookup_match(lock, alias):
|
|
87
|
+
lock._state_data = {"states": [state(alias, "Closed"), state(alias, "Open")]}
|
|
88
|
+
assert lock.door_state == "Closed"
|
|
89
|
+
assert lock.is_door_open is False
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@pytest.mark.parametrize("entry_point", ["query", "push"])
|
|
93
|
+
@pytest.mark.parametrize("alias", ALIASES)
|
|
94
|
+
async def test_update_paths_track_door_transitions(lock, mock_api, entry_point, alias):
|
|
95
|
+
for value in ("Open", "Closed", "Open"):
|
|
96
|
+
snapshot = {"id": lock.device_id, "states": [state(alias, value)]}
|
|
97
|
+
if entry_point == "query":
|
|
98
|
+
mock_api.query_device.return_value = {"payload": {"devices": [snapshot]}}
|
|
99
|
+
await lock.update()
|
|
100
|
+
mock_api.query_device.assert_awaited_with(lock.device_id)
|
|
101
|
+
else:
|
|
102
|
+
await lock.update_state_data(snapshot)
|
|
103
|
+
assert lock.has_door_sensor is True
|
|
104
|
+
assert lock.door_state == value
|
|
105
|
+
assert lock.is_door_open is (value == "Open")
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"""Tests for Lock device."""
|
|
2
2
|
|
|
3
|
+
from unittest.mock import AsyncMock
|
|
4
|
+
|
|
3
5
|
import pytest
|
|
4
6
|
|
|
7
|
+
from utec_client.devices.device_const import LOCK_MODE_LABELS, LockMode
|
|
5
8
|
from utec_client.devices.lock import Lock
|
|
9
|
+
from utec_client.exceptions import DeviceError
|
|
6
10
|
|
|
7
11
|
|
|
8
12
|
@pytest.fixture
|
|
@@ -182,6 +186,68 @@ def test_lock_mode_returns_none_when_missing(lock):
|
|
|
182
186
|
assert lock.lock_mode is None
|
|
183
187
|
|
|
184
188
|
|
|
189
|
+
def test_lock_mode_labels_is_read_only():
|
|
190
|
+
with pytest.raises(TypeError):
|
|
191
|
+
LOCK_MODE_LABELS[LockMode.NORMAL] = "Changed"
|
|
192
|
+
with pytest.raises(TypeError):
|
|
193
|
+
del LOCK_MODE_LABELS[LockMode.NORMAL]
|
|
194
|
+
assert LOCK_MODE_LABELS[LockMode.NORMAL] == "Normal"
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def test_lock_mode_labels_cover_every_mode():
|
|
198
|
+
assert set(LOCK_MODE_LABELS) == set(LockMode)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
# set_mode
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@pytest.mark.asyncio
|
|
205
|
+
@pytest.mark.parametrize(
|
|
206
|
+
"mode, value",
|
|
207
|
+
[
|
|
208
|
+
(LockMode.NORMAL, 0),
|
|
209
|
+
(LockMode.PASSAGE, 1),
|
|
210
|
+
(LockMode.LOCKED, 2),
|
|
211
|
+
],
|
|
212
|
+
)
|
|
213
|
+
async def test_set_mode_sends_set_mode_command(lock, mock_api, mode, value):
|
|
214
|
+
await lock.set_mode(mode)
|
|
215
|
+
mock_api.send_command.assert_awaited_once_with(
|
|
216
|
+
lock.device_id, "st.lock", "setMode", {"mode": value}
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@pytest.mark.asyncio
|
|
221
|
+
async def test_set_mode_payload_matches_openapi(lock, mock_api):
|
|
222
|
+
"""The command must match the OpenAPI 'Lock Mode Setting' example.
|
|
223
|
+
|
|
224
|
+
https://doc.api.u-tec.com/ -> Device Control Command -> Lock Mode Setting
|
|
225
|
+
"""
|
|
226
|
+
lock.send_command = AsyncMock(wraps=lock.send_command)
|
|
227
|
+
await lock.set_mode(LockMode.PASSAGE)
|
|
228
|
+
|
|
229
|
+
assert lock.send_command.await_args.args[0].to_dict() == {
|
|
230
|
+
"capability": "st.lock",
|
|
231
|
+
"name": "setMode",
|
|
232
|
+
"arguments": {"mode": 1},
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
@pytest.mark.asyncio
|
|
237
|
+
@pytest.mark.parametrize("mode", [1, True, 1.0, "Passage", None, 3])
|
|
238
|
+
async def test_set_mode_rejects_non_lockmode(lock, mock_api, mode):
|
|
239
|
+
with pytest.raises(ValueError, match="must be a LockMode member"):
|
|
240
|
+
await lock.set_mode(mode)
|
|
241
|
+
mock_api.send_command.assert_not_awaited()
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
@pytest.mark.asyncio
|
|
245
|
+
async def test_set_mode_wraps_failure_as_device_error(lock, mock_api):
|
|
246
|
+
mock_api.send_command.side_effect = RuntimeError("boom")
|
|
247
|
+
with pytest.raises(DeviceError, match="boom"):
|
|
248
|
+
await lock.set_mode(LockMode.NORMAL)
|
|
249
|
+
|
|
250
|
+
|
|
185
251
|
# is_jammed
|
|
186
252
|
|
|
187
253
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|