Skip to content

Commit

Permalink
fix: add tests for pergola and awning
Browse files Browse the repository at this point in the history
  • Loading branch information
muhlba91 committed Dec 11, 2023
1 parent 3b4d1ba commit d9fb32c
Showing 1 changed file with 146 additions and 0 deletions.
146 changes: 146 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,152 @@ async def test_device_shutter_no_data(self, mock_response, client):
assert device.actual_position is None
assert device.actual_angle is None

@pytest.mark.asyncio
async def test_device_pergola_awning_roof(self, mock_response, client):
mock_response.get(
f"{API_URL}/box/finger/api/{API_VERSION}/devices/device",
status=200,
payload={
"name": "device",
"type": "pergola_awning_roof",
"actions": ["close", "open", "stop", "wink"],
"properties": {
"actual_angle": {
"type": "numeric",
"minimum": 0,
"maximum": 360,
"value": 0,
"readonly": True,
},
"actual_position": {
"type": "numeric",
"minimum": 0,
"maximum": 100,
"value": 100,
"readonly": True,
},
"system_state": {
"type": "enumeration",
"value": "ok",
"values": [
"collision",
"collision_not_calibrated",
"not_calibrated",
"ok",
],
"readonly": True,
},
"target_angle": {
"type": "numeric",
"minimum": 0,
"maximum": 360,
"value": 0,
"readonly": False,
},
"target_position": {
"type": "numeric",
"minimum": 0,
"maximum": 100,
"value": 100,
"readonly": False,
},
},
},
)
device = await client.device("device")
assert isinstance(device, Shutter)
assert device.device_type == DeviceType.PERGOLA_AWNING_ROOF
assert device.device_mode.mode is None
assert len(device.device_mode.values) == 0
assert device.actions == [Action.CLOSE, Action.OPEN, Action.STOP, Action.WINK]
assert device.target_position == NumericValue(100, 0, 100, False)
assert device.target_angle == NumericValue(0, 0, 360, False)
assert device.actual_position == NumericValue(
100,
0,
100,
False,
)
assert device.actual_angle == NumericValue(
0,
0,
360,
False,
)

@pytest.mark.asyncio
async def test_device_awning(self, mock_response, client):
mock_response.get(
f"{API_URL}/box/finger/api/{API_VERSION}/devices/device",
status=200,
payload={
"name": "device",
"type": "awning",
"actions": ["close", "open", "stop", "wink"],
"properties": {
"actual_angle": {
"type": "numeric",
"minimum": 0,
"maximum": 360,
"value": 0,
"readonly": True,
},
"actual_position": {
"type": "numeric",
"minimum": 0,
"maximum": 100,
"value": 0,
"readonly": True,
},
"system_state": {
"type": "enumeration",
"value": "ok",
"values": [
"collision",
"collision_not_calibrated",
"not_calibrated",
"ok",
],
"readonly": True,
},
"target_angle": {
"type": "numeric",
"minimum": 0,
"maximum": 360,
"value": 0,
"readonly": False,
},
"target_position": {
"type": "numeric",
"minimum": 0,
"maximum": 100,
"value": 0,
"readonly": False,
},
},
},
)
device = await client.device("device")
assert isinstance(device, Shutter)
assert device.device_type == DeviceType.AWNING
assert device.device_mode.mode is None
assert len(device.device_mode.values) == 0
assert device.actions == [Action.CLOSE, Action.OPEN, Action.STOP, Action.WINK]
assert device.target_position == NumericValue(0, 0, 100, False)
assert device.target_angle == NumericValue(0, 0, 360, False)
assert device.actual_position == NumericValue(
0,
0,
100,
False,
)
assert device.actual_angle == NumericValue(
0,
0,
360,
False,
)

@pytest.mark.asyncio
async def test_device_weather(self, mock_response, client):
mock_response.get(
Expand Down

0 comments on commit d9fb32c

Please sign in to comment.