@@ -8,11 +8,10 @@ import org.springframework.boot.test.context.SpringBootTest
8
8
import org.springframework.web.client.RestClient
9
9
import tadoclient.Application
10
10
import tadoclient.TadoConfig
11
+ import tadoclient.models.ChildLock
12
+ import tadoclient.models.MoveDeviceRequest
11
13
import tadoclient.models.Temperature
12
- import tadoclient.verify.assertCorrectResponse
13
- import tadoclient.verify.verifyDevice
14
- import tadoclient.verify.verifyDeviceListItem
15
- import tadoclient.verify.verifyNested
14
+ import tadoclient.verify.*
16
15
import kotlin.test.Test
17
16
import kotlin.test.assertEquals
18
17
import kotlin.test.assertNotEquals
@@ -24,10 +23,14 @@ class DeviceApi_IT (
24
23
@Qualifier(" tadoStrictRestClient" )
25
24
val tadoStrictRestClient : RestClient ,
26
25
26
+ @Qualifier(" tadoRestClient" )
27
+ val tadoRestClient : RestClient ,
28
+
27
29
@Autowired
28
30
tadoConfig : TadoConfig
29
31
): BaseTest(tadoConfig) {
30
32
val tadoStrictDeviceAPI = DeviceApi (tadoStrictRestClient)
33
+ val tadoDeviceAPI = DeviceApi (tadoRestClient)
31
34
32
35
@Test
33
36
@DisplayName(" GET /devices/{deviceId}" )
@@ -39,6 +42,17 @@ class DeviceApi_IT (
39
42
verifyDevice(device, endpoint)
40
43
}
41
44
45
+ @Test
46
+ @DisplayName(" PUT /devices/{deviceId}/childLock" )
47
+ @Order(5 )
48
+ @EnabledIf(value = " isThermostatDeviceConfigured" , disabledReason = " no thermostat device specified in tado set-up" )
49
+ fun setChildLock () {
50
+ // first get the current child lock setting
51
+ val device = tadoDeviceAPI.getDevice(tadoConfig.device!! .thermostat!! .id)
52
+ // then test by re-setting the same childLock setting
53
+ tadoStrictDeviceAPI.setChildLock(tadoConfig.device!! .thermostat!! .id, ChildLock (device.childLockEnabled))
54
+ }
55
+
42
56
@Test
43
57
@DisplayName(" POST /devices/{deviceId}/identify" )
44
58
@Order(10 )
@@ -55,18 +69,18 @@ class DeviceApi_IT (
55
69
val endpoint = " GET /devices/{deviceId}/temperatureOffset"
56
70
val offset = assertCorrectResponse { tadoStrictDeviceAPI.getTemperatureOffset(tadoConfig.device!! .thermostat!! .id) }
57
71
val typeName = " TemperatureOffset"
58
- verifyNested (offset, endpoint, typeName, typeName)
72
+ verifyObject (offset, endpoint, typeName, typeName)
59
73
}
60
74
61
75
@Test
62
76
@DisplayName(" PUT /devices/{deviceId}/temperatureOffset" )
63
77
@Order(30 )
64
78
@EnabledIf(value = " isThermostatDeviceConfigured" , disabledReason = " no thermostat device specified in tado set-up" )
65
79
fun putTemperatureOffset () {
66
- val endpoint = " OYT /devices/{deviceId}/temperatureOffset"
80
+ val endpoint = " PUT /devices/{deviceId}/temperatureOffset"
67
81
val offset = assertCorrectResponse { tadoStrictDeviceAPI.setTemperatureOffset(tadoConfig.device!! .thermostat!! .id, Temperature (0.5f )) }
68
82
val typeName = " TemperatureOffset"
69
- verifyNested (offset, endpoint, typeName, typeName)
83
+ verifyObject (offset, endpoint, typeName, typeName)
70
84
}
71
85
72
86
@Test
@@ -107,11 +121,18 @@ class DeviceApi_IT (
107
121
fun getInstallations () {
108
122
val endpoint = " GET /homes/{homeId}/installations"
109
123
val installations = assertCorrectResponse { tadoStrictDeviceAPI.getInstallations(tadoConfig.home!! .id) }
124
+ // observation: returned an empty array until an aircon controller was added to the home
125
+ installations.forEachIndexed { i, elem -> verifyInstallation(elem, endpoint, " response[$i ]" ) }
126
+ }
110
127
111
- // returns AC installations
112
- assertEquals(1 , installations.size)
113
-
114
- // todo: implement an verifyInstallation method
128
+ @Test
129
+ @DisplayName(" GET /homes/{homeId}/installations/{installationId}" )
130
+ @Order(66 )
131
+ @EnabledIf(value = " isInstallationConfigured" , disabledReason = " no home specified in tado set-up" )
132
+ fun getInstallation () {
133
+ val endpoint = " GET /homes/{homeId}/installations/{installationId}"
134
+ val installation = assertCorrectResponse { tadoStrictDeviceAPI.getInstallation(tadoConfig.home!! .id, tadoConfig.installation!! .id) }
135
+ verifyInstallation(installation, endpoint)
115
136
}
116
137
117
138
@Test
@@ -123,7 +144,7 @@ class DeviceApi_IT (
123
144
val zoneControl = assertCorrectResponse { tadoStrictDeviceAPI.getZoneControl(tadoConfig.home!! .id, tadoConfig.zone!! .heating!! .id) }
124
145
125
146
val typeName = " ZoneControl"
126
- verifyNested (zoneControl, endpoint, endpoint, typeName,
147
+ verifyObject (zoneControl, endpoint, endpoint, typeName,
127
148
nullAllowedProperties = listOf (
128
149
" $typeName .duties.driver" ,
129
150
" $typeName .duties.drivers" ,
@@ -134,12 +155,14 @@ class DeviceApi_IT (
134
155
)
135
156
}
136
157
158
+ // integration test for "GET /homes/{homeId}/zones/{zoneId}/control"
159
+ // see HeatingCircuitAPI_IT
160
+
137
161
@Test
138
- @DisplayName(" PUT /homes/{homeId}/zones/{zoneId}/control/heatingCircuit " )
162
+ @DisplayName(" POST /homes/{homeId}/zones/{zoneId}/devices " )
139
163
@Order(80 )
140
- @Disabled(" to be implemented" )
141
- fun putControl () {
142
- // TODO: to be implemented
164
+ @Disabled(" needs more analysis" )
165
+ fun moveDevice () {
143
166
}
144
167
145
168
@Test
@@ -155,9 +178,14 @@ class DeviceApi_IT (
155
178
@Test
156
179
@DisplayName(" PUT /homes/{homeId}/zones/{zoneId}/measuringDevice" )
157
180
@Order(100 )
158
- @Disabled( " not yet implemented " )
181
+ @EnabledIf(value = " isHomeAndHeatingZoneConfigured " , disabledReason = " no home specified in tado set-up " )
159
182
fun putMeasuringDevice () {
160
- // TODO: to be implemented
183
+ // first get the current measuring device and simply put the same one again
184
+ val measuringDevice = tadoDeviceAPI.getZoneMeasuringDevice(tadoConfig.home!! .id, tadoConfig.zone!! .heating!! .id)
185
+ // now test
186
+ val endpoint = " PUT /homes/{homeId}/zones/{zoneId}/measuringDevice"
187
+ val device = assertCorrectResponse { tadoStrictDeviceAPI.setZoneMeasuringDevice(tadoConfig.home.id, tadoConfig.zone.heating!! .id, MoveDeviceRequest (measuringDevice.serialNo)) }
188
+ verifyDevice(device, endpoint)
161
189
}
162
190
163
191
}
0 commit comments