Skip to content

Commit bd4f702

Browse files
committed
Correct/improve constant imports
1 parent 11136d9 commit bd4f702

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

tests/components/plugwise/test_button.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
from unittest.mock import MagicMock
44

5-
from homeassistant.components.button import ButtonDeviceClass
5+
from homeassistant.components.button import (
6+
ButtonDeviceClass,
7+
DOMAIN as BUTTON_DOMAIN,
8+
SERVICE_PRESS,
9+
)
610
from homeassistant.const import (
711
ATTR_DEVICE_CLASS,
812
ATTR_ENTITY_ID,
913
STATE_UNKNOWN,
10-
Platform,
1114
)
1215
from homeassistant.core import HomeAssistant
1316
from homeassistant.helpers import entity_registry as er
@@ -30,8 +33,8 @@ async def test_adam_reboot_button(
3033
assert entry.unique_id == "fe799307f1624099878210aa0b9f1475-reboot"
3134

3235
await hass.services.async_call(
33-
Platform.BUTTON,
34-
"press",
36+
BUTTON_DOMAIN,
37+
SERVICE_PRESS,
3538
{ATTR_ENTITY_ID: "button.adam_reboot"},
3639
blocking=True,
3740
)

tests/components/plugwise/test_climate.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
import pytest
99

1010
from freezegun.api import FrozenDateTimeFactory
11-
from homeassistant.components.climate.const import HVACMode
11+
from homeassistant.components.climate import (
12+
DOMAIN as CLIMATE_DOMAIN,
13+
HVACMode,
14+
SERVICE_SET_HVAC_MODE,
15+
SERVICE_SET_PRESET_MODE,
16+
SERVICE_SET_TEMPERATURE,
17+
)
1218
from homeassistant.core import HomeAssistant
1319
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
1420

@@ -174,8 +180,8 @@ async def test_adam_climate_adjust_negative_testing(
174180

175181
with pytest.raises(HomeAssistantError):
176182
await hass.services.async_call(
177-
"climate",
178-
"set_temperature",
183+
CLIMATE_DOMAIN,
184+
SERVICE_SET_TEMPERATURE,
179185
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
180186
blocking=True,
181187
)
@@ -186,8 +192,8 @@ async def test_adam_climate_entity_climate_changes(
186192
) -> None:
187193
"""Test handling of user requests in adam climate device environment."""
188194
await hass.services.async_call(
189-
"climate",
190-
"set_temperature",
195+
CLIMATE_DOMAIN,
196+
SERVICE_SET_TEMPERATURE,
191197
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
192198
blocking=True,
193199
)
@@ -197,8 +203,8 @@ async def test_adam_climate_entity_climate_changes(
197203
)
198204

199205
await hass.services.async_call(
200-
"climate",
201-
"set_temperature",
206+
CLIMATE_DOMAIN,
207+
SERVICE_SET_TEMPERATURE,
202208
{
203209
"entity_id": "climate.zone_lisa_wk",
204210
"hvac_mode": "heat",
@@ -213,15 +219,15 @@ async def test_adam_climate_entity_climate_changes(
213219

214220
with pytest.raises(ServiceValidationError):
215221
await hass.services.async_call(
216-
"climate",
217-
"set_temperature",
222+
CLIMATE_DOMAIN,
223+
SERVICE_SET_TEMPERATURE,
218224
{"entity_id": "climate.zone_lisa_wk", "temperature": 150},
219225
blocking=True,
220226
)
221227

222228
await hass.services.async_call(
223-
"climate",
224-
"set_preset_mode",
229+
CLIMATE_DOMAIN,
230+
SERVICE_SET_PRESET_MODE,
225231
{"entity_id": "climate.zone_lisa_wk", "preset_mode": "away"},
226232
blocking=True,
227233
)
@@ -231,8 +237,8 @@ async def test_adam_climate_entity_climate_changes(
231237
)
232238

233239
await hass.services.async_call(
234-
"climate",
235-
"set_hvac_mode",
240+
CLIMATE_DOMAIN,
241+
SERVICE_SET_HVAC_MODE,
236242
{"entity_id": "climate.zone_lisa_wk", "hvac_mode": "heat"},
237243
blocking=True,
238244
)
@@ -243,8 +249,8 @@ async def test_adam_climate_entity_climate_changes(
243249

244250
with pytest.raises(HomeAssistantError):
245251
await hass.services.async_call(
246-
"climate",
247-
"set_hvac_mode",
252+
CLIMATE_DOMAIN,
253+
SERVICE_SET_HVAC_MODE,
248254
{
249255
"entity_id": "climate.zone_thermostat_jessie",
250256
"hvac_mode": "dry",
@@ -263,8 +269,8 @@ async def test_adam_climate_off_mode_change(
263269
assert state
264270
assert state.state == HVACMode.OFF
265271
await hass.services.async_call(
266-
"climate",
267-
"set_hvac_mode",
272+
CLIMATE_DOMAIN,
273+
SERVICE_SET_HVAC_MODE,
268274
{
269275
"entity_id": "climate.slaapkamer",
270276
"hvac_mode": "heat",
@@ -279,8 +285,8 @@ async def test_adam_climate_off_mode_change(
279285
assert state
280286
assert state.state == HVACMode.HEAT
281287
await hass.services.async_call(
282-
"climate",
283-
"set_hvac_mode",
288+
CLIMATE_DOMAIN,
289+
SERVICE_SET_HVAC_MODE,
284290
{
285291
"entity_id": "climate.kinderkamer",
286292
"hvac_mode": "off",
@@ -295,8 +301,8 @@ async def test_adam_climate_off_mode_change(
295301
assert state
296302
assert state.state == HVACMode.HEAT
297303
await hass.services.async_call(
298-
"climate",
299-
"set_hvac_mode",
304+
CLIMATE_DOMAIN,
305+
SERVICE_SET_HVAC_MODE,
300306
{
301307
"entity_id": "climate.logeerkamer",
302308
"hvac_mode": "heat",
@@ -378,8 +384,8 @@ async def test_anna_climate_entity_climate_changes(
378384
) -> None:
379385
"""Test handling of user requests in anna climate device environment."""
380386
await hass.services.async_call(
381-
"climate",
382-
"set_temperature",
387+
CLIMATE_DOMAIN,
388+
SERVICE_SET_TEMPERATURE,
383389
{"entity_id": "climate.anna", "target_temp_high": 30, "target_temp_low": 20},
384390
blocking=True,
385391
)
@@ -390,8 +396,8 @@ async def test_anna_climate_entity_climate_changes(
390396
)
391397

392398
await hass.services.async_call(
393-
"climate",
394-
"set_preset_mode",
399+
CLIMATE_DOMAIN,
400+
SERVICE_SET_PRESET_MODE,
395401
{"entity_id": "climate.anna", "preset_mode": "away"},
396402
blocking=True,
397403
)
@@ -401,17 +407,17 @@ async def test_anna_climate_entity_climate_changes(
401407
)
402408

403409
await hass.services.async_call(
404-
"climate",
405-
"set_hvac_mode",
410+
CLIMATE_DOMAIN,
411+
SERVICE_SET_HVAC_MODE,
406412
{"entity_id": "climate.anna", "hvac_mode": "auto"},
407413
blocking=True,
408414
)
409415
assert mock_smile_anna.set_schedule_state.call_count == 0
410416
# hvac_mode is already auto so not called.
411417

412418
await hass.services.async_call(
413-
"climate",
414-
"set_hvac_mode",
419+
CLIMATE_DOMAIN,
420+
SERVICE_SET_HVAC_MODE,
415421
{"entity_id": "climate.anna", "hvac_mode": "heat_cool"},
416422
blocking=True,
417423
)

tests/components/plugwise/test_number.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
from unittest.mock import MagicMock
44

5-
from homeassistant.components.number import ATTR_VALUE, SERVICE_SET_VALUE
6-
from homeassistant.const import ATTR_ENTITY_ID, Platform
5+
from homeassistant.components.number import (
6+
ATTR_VALUE,
7+
DOMAIN as NUMBER_DOMAIN,
8+
SERVICE_SET_VALUE,
9+
)
10+
from homeassistant.const import ATTR_ENTITY_ID
711
from homeassistant.core import HomeAssistant
812

913
from tests.common import MockConfigEntry
@@ -23,7 +27,7 @@ async def test_anna_max_boiler_temp_change(
2327
) -> None:
2428
"""Test changing of number entities."""
2529
await hass.services.async_call(
26-
Platform.NUMBER,
30+
NUMBER_DOMAIN,
2731
SERVICE_SET_VALUE,
2832
{
2933
ATTR_ENTITY_ID: "number.opentherm_maximum_boiler_temperature_setpoint",
@@ -43,7 +47,7 @@ async def test_adam_dhw_setpoint_change(
4347
) -> None:
4448
"""Test changing of number entities."""
4549
await hass.services.async_call(
46-
Platform.NUMBER,
50+
NUMBER_DOMAIN,
4751
SERVICE_SET_VALUE,
4852
{
4953
ATTR_ENTITY_ID: "number.opentherm_domestic_hot_water_setpoint",
@@ -75,7 +79,7 @@ async def test_adam_temperature_offset_change(
7579
) -> None:
7680
"""Test changing of the temperature_offset number."""
7781
await hass.services.async_call(
78-
Platform.NUMBER,
82+
NUMBER_DOMAIN,
7983
SERVICE_SET_VALUE,
8084
{
8185
ATTR_ENTITY_ID: "number.zone_thermostat_jessie_temperature_offset",

0 commit comments

Comments
 (0)