Improve imports in deCONZ tests (#41976)
* Improve imports in deconz tests * Add spacing
This commit is contained in:
1 parent
1b94ef69d8
commit
7eb532ddd0
15 files changed
+547
-398
No files matched your search
@@ -1,9 +1,16 @@
|
||||
"""deCONZ cover platform tests."""
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from homeassistant.components import deconz
|
||||
import homeassistant.components.cover as cover
|
||||
from homeassistant.components.cover import (
|
||||
DOMAIN as COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
SERVICE_OPEN_COVER,
|
||||
SERVICE_STOP_COVER,
|
||||
)
|
||||
from homeassistant.components.deconz.const import DOMAIN as DECONZ_DOMAIN
|
||||
from homeassistant.components.deconz.gateway import get_gateway_from_config_entry
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_CLOSED, STATE_OPEN
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .test_gateway import DECONZ_WEB_REQUEST, setup_deconz_integration
|
||||
@@ -57,11 +64,11 @@ async def test_platform_manually_configured(hass):
|
||||
"""Test that we do not discover anything or try to set up a gateway."""
|
||||
assert (
|
||||
await async_setup_component(
|
||||
hass, cover.DOMAIN, {"cover": {"platform": deconz.DOMAIN}}
|
||||
hass, COVER_DOMAIN, {"cover": {"platform": DECONZ_DOMAIN}}
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert deconz.DOMAIN not in hass.data
|
||||
assert DECONZ_DOMAIN not in hass.data
|
||||
|
||||
|
||||
async def test_no_covers(hass):
|
||||
@@ -78,11 +85,11 @@ async def test_cover(hass):
|
||||
gateway = get_gateway_from_config_entry(hass, config_entry)
|
||||
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert hass.states.get("cover.level_controllable_cover").state == "open"
|
||||
assert hass.states.get("cover.window_covering_device").state == "closed"
|
||||
assert hass.states.get("cover.level_controllable_cover").state == STATE_OPEN
|
||||
assert hass.states.get("cover.window_covering_device").state == STATE_CLOSED
|
||||
assert hass.states.get("cover.unsupported_cover") is None
|
||||
assert hass.states.get("cover.deconz_old_brightness_cover").state == "open"
|
||||
assert hass.states.get("cover.window_covering_controller").state == "closed"
|
||||
assert hass.states.get("cover.deconz_old_brightness_cover").state == STATE_OPEN
|
||||
assert hass.states.get("cover.window_covering_controller").state == STATE_CLOSED
|
||||
|
||||
# Event signals cover is closed
|
||||
|
||||
@@ -96,7 +103,7 @@ async def test_cover(hass):
|
||||
gateway.api.event_handler(state_changed_event)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get("cover.level_controllable_cover").state == "closed"
|
||||
assert hass.states.get("cover.level_controllable_cover").state == STATE_CLOSED
|
||||
|
||||
# Verify service calls
|
||||
|
||||
@@ -108,9 +115,9 @@ async def test_cover(hass):
|
||||
level_controllable_cover_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
cover.DOMAIN,
|
||||
cover.SERVICE_OPEN_COVER,
|
||||
{"entity_id": "cover.level_controllable_cover"},
|
||||
COVER_DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: "cover.level_controllable_cover"},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
@@ -122,9 +129,9 @@ async def test_cover(hass):
|
||||
level_controllable_cover_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
cover.DOMAIN,
|
||||
cover.SERVICE_CLOSE_COVER,
|
||||
{"entity_id": "cover.level_controllable_cover"},
|
||||
COVER_DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: "cover.level_controllable_cover"},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
@@ -138,16 +145,16 @@ async def test_cover(hass):
|
||||
level_controllable_cover_device, "_request", return_value=True
|
||||
) as set_callback:
|
||||
await hass.services.async_call(
|
||||
cover.DOMAIN,
|
||||
cover.SERVICE_STOP_COVER,
|
||||
{"entity_id": "cover.level_controllable_cover"},
|
||||
COVER_DOMAIN,
|
||||
SERVICE_STOP_COVER,
|
||||
{ATTR_ENTITY_ID: "cover.level_controllable_cover"},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
set_callback.assert_called_with("put", "/lights/1/state", json={"bri_inc": 0})
|
||||
|
||||
# Test that a reported cover position of 255 (deconz-rest-api < 2.05.73) is interpreted correctly.
|
||||
assert hass.states.get("cover.deconz_old_brightness_cover").state == "open"
|
||||
assert hass.states.get("cover.deconz_old_brightness_cover").state == STATE_OPEN
|
||||
|
||||
state_changed_event = {
|
||||
"t": "event",
|
||||
@@ -160,7 +167,7 @@ async def test_cover(hass):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
deconz_old_brightness_cover = hass.states.get("cover.deconz_old_brightness_cover")
|
||||
assert deconz_old_brightness_cover.state == "closed"
|
||||
assert deconz_old_brightness_cover.state == STATE_CLOSED
|
||||
assert deconz_old_brightness_cover.attributes["current_position"] == 0
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
Reference in new issue
Block a user