2016-11-24 17:52:15 +00:00
|
|
|
"""The tests for the litejet component."""
|
2021-02-23 20:20:58 +00:00
|
|
|
from homeassistant.components import scene
|
|
|
|
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON
|
2021-03-09 13:32:08 +00:00
|
|
|
from homeassistant.helpers import entity_registry as er
|
2016-11-24 17:52:15 +00:00
|
|
|
|
2021-02-23 20:20:58 +00:00
|
|
|
from . import async_init_integration
|
2016-11-24 17:52:15 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
ENTITY_SCENE = "scene.mock_scene_1"
|
2016-11-24 17:52:15 +00:00
|
|
|
ENTITY_SCENE_NUMBER = 1
|
2019-07-31 19:25:30 +00:00
|
|
|
ENTITY_OTHER_SCENE = "scene.mock_scene_2"
|
2016-11-24 17:52:15 +00:00
|
|
|
ENTITY_OTHER_SCENE_NUMBER = 2
|
|
|
|
|
|
|
|
|
2021-02-23 20:20:58 +00:00
|
|
|
async def test_disabled_by_default(hass, mock_litejet):
|
|
|
|
"""Test the scene is disabled by default."""
|
|
|
|
await async_init_integration(hass)
|
|
|
|
|
2021-03-09 13:32:08 +00:00
|
|
|
registry = er.async_get(hass)
|
2021-02-23 20:20:58 +00:00
|
|
|
|
|
|
|
state = hass.states.get(ENTITY_SCENE)
|
|
|
|
assert state is None
|
|
|
|
|
|
|
|
entry = registry.async_get(ENTITY_SCENE)
|
|
|
|
assert entry
|
|
|
|
assert entry.disabled
|
2021-04-23 07:56:42 +00:00
|
|
|
assert entry.disabled_by == er.DISABLED_INTEGRATION
|
2021-02-23 20:20:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_activate(hass, mock_litejet):
|
|
|
|
"""Test activating the scene."""
|
|
|
|
|
|
|
|
await async_init_integration(hass, use_scene=True)
|
|
|
|
|
|
|
|
state = hass.states.get(ENTITY_SCENE)
|
|
|
|
assert state is not None
|
|
|
|
|
|
|
|
await hass.services.async_call(
|
|
|
|
scene.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_SCENE}, blocking=True
|
|
|
|
)
|
|
|
|
|
|
|
|
mock_litejet.activate_scene.assert_called_once_with(ENTITY_SCENE_NUMBER)
|