Add SmartThings Scene platform (#21405)
* Add SmartThings Scene platform * Fixed failing tests after rebase * Update cover tests.
This commit is contained in:
1 parent
344e839bec
commit
3b9db88065
14 files changed
+266
-72
No files matched your search
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
Test for the SmartThings scene platform.
|
||||
|
||||
The only mocking required is of the underlying SmartThings API object so
|
||||
real HTTP calls are not initiated during testing.
|
||||
"""
|
||||
from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN
|
||||
from homeassistant.components.smartthings import scene as scene_platform
|
||||
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON
|
||||
|
||||
from .conftest import setup_platform
|
||||
|
||||
|
||||
async def test_async_setup_platform():
|
||||
"""Test setup platform does nothing (it uses config entries)."""
|
||||
await scene_platform.async_setup_platform(None, None, None)
|
||||
|
||||
|
||||
async def test_entity_and_device_attributes(hass, scene):
|
||||
"""Test the attributes of the entity are correct."""
|
||||
# Arrange
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
# Act
|
||||
await setup_platform(hass, SCENE_DOMAIN, scenes=[scene])
|
||||
# Assert
|
||||
entry = entity_registry.async_get('scene.test_scene')
|
||||
assert entry
|
||||
assert entry.unique_id == scene.scene_id
|
||||
|
||||
|
||||
async def test_scene_activate(hass, scene):
|
||||
"""Test the scene is activated."""
|
||||
await setup_platform(hass, SCENE_DOMAIN, scenes=[scene])
|
||||
await hass.services.async_call(
|
||||
SCENE_DOMAIN, SERVICE_TURN_ON, {
|
||||
ATTR_ENTITY_ID: 'scene.test_scene'},
|
||||
blocking=True)
|
||||
state = hass.states.get('scene.test_scene')
|
||||
assert state.attributes['icon'] == scene.icon
|
||||
assert state.attributes['color'] == scene.color
|
||||
assert state.attributes['location_id'] == scene.location_id
|
||||
# pylint: disable=protected-access
|
||||
assert scene._api.execute_scene.call_count == 1 # type: ignore
|
||||
|
||||
|
||||
async def test_unload_config_entry(hass, scene):
|
||||
"""Test the scene is removed when the config entry is unloaded."""
|
||||
# Arrange
|
||||
config_entry = await setup_platform(hass, SCENE_DOMAIN, scenes=[scene])
|
||||
# Act
|
||||
await hass.config_entries.async_forward_entry_unload(
|
||||
config_entry, SCENE_DOMAIN)
|
||||
# Assert
|
||||
assert not hass.states.get('scene.test_scene')
|
||||
Reference in new issue
Block a user