Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Dec 28, 2024
1 parent 511d93f commit 894b3e3
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PyTado/interface/api/hops_tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_devices(self):
serial_number = device.get("serialNo", device.get("serialNumber"))
if not serial_number:
continue

request = TadoXRequest()
request.domain = Domain.DEVICES
request.device = serial_number
Expand Down
64 changes: 64 additions & 0 deletions tests/fixtures/tadox/rooms_and_devices.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"otherDevices": [
{
"connection": {
"state": "CONNECTED"
},
"firmwareVersion": "245.1",
"serialNumber": "IB1234567890",
"type": "IB02"
}
],
"rooms": [
{
"deviceManualControlTermination": {
"durationInSeconds": null,
"type": "MANUAL"
},
"devices": [
{
"batteryState": "NORMAL",
"childLockEnabled": false,
"connection": {
"state": "CONNECTED"
},
"firmwareVersion": "243.1",
"mountingState": "CALIBRATED",
"serialNumber": "VA1234567890",
"temperatureAsMeasured": 17.00,
"temperatureOffset": 0.0,
"type": "VA04"
}
],
"roomId": 1,
"roomName": "Room 1 ",
"zoneControllerAssignable": false,
"zoneControllers": []
},
{
"deviceManualControlTermination": {
"durationInSeconds": null,
"type": "MANUAL"
},
"devices": [
{
"batteryState": "NORMAL",
"childLockEnabled": false,
"connection": {
"state": "CONNECTED"
},
"firmwareVersion": "243.1",
"mountingState": "CALIBRATED",
"serialNumber": "VA1234567891",
"temperatureAsMeasured": 18.00,
"temperatureOffset": 0.0,
"type": "VA04"
}
],
"roomId": 2,
"roomName": " Room 2",
"zoneControllerAssignable": false,
"zoneControllers": []
}
]
}
22 changes: 22 additions & 0 deletions tests/test_hops_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ def check_get_state(zone_id):
get_state_patch.start()
self.addCleanup(get_state_patch.stop)

def set_get_devices_fixture(self, filename: str) -> None:
def get_devices():
return json.loads(common.load_fixture(filename))

get_devices_patch = mock.patch(
"PyTado.interface.api.TadoX.get_devices",
side_effect=get_devices,
)
get_devices_patch.start()
self.addCleanup(get_devices_patch.stop)

def test_tadox_heating_auto_mode(self):
"""Test general homes response."""

Expand Down Expand Up @@ -145,3 +156,14 @@ def test_tadox_heating_manual_off(self):
assert mode.tado_mode is None
assert mode.target_temp is None
assert mode.zone_id == 1

def test_get_devices(self):
""" Test get_devices method """
self.set_get_devices_fixture("tadox/rooms_and_devices.json")

devices_and_rooms = self.tado_client.get_devices()
rooms = devices_and_rooms['rooms']
assert len(rooms) == 2
room_1 = rooms[0]
assert room_1['roomName'] == 'Room 1'
assert room_1['devices'][0]['serialNumber'] == 'VA1234567890'

0 comments on commit 894b3e3

Please sign in to comment.