2016-12-01 20:48:08 +00:00
|
|
|
"""The tests for the demo remote component."""
|
|
|
|
# pylint: disable=protected-access
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import homeassistant.components.remote as remote
|
2019-12-08 16:59:27 +00:00
|
|
|
from homeassistant.const import STATE_OFF, STATE_ON
|
|
|
|
from homeassistant.setup import setup_component
|
2018-09-26 16:02:05 +00:00
|
|
|
|
2017-08-01 03:52:39 +00:00
|
|
|
from tests.common import get_test_home_assistant
|
2018-09-26 16:02:05 +00:00
|
|
|
from tests.components.remote import common
|
2016-12-01 20:48:08 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
ENTITY_ID = "remote.remote_one"
|
2016-12-01 20:48:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestDemoRemote(unittest.TestCase):
|
|
|
|
"""Test the demo remote."""
|
|
|
|
|
|
|
|
# pylint: disable=invalid-name
|
|
|
|
def setUp(self):
|
2018-08-19 20:29:08 +00:00
|
|
|
"""Set up things to be run when tests are started."""
|
2016-12-01 20:48:08 +00:00
|
|
|
self.hass = get_test_home_assistant()
|
2019-07-31 19:25:30 +00:00
|
|
|
assert setup_component(
|
|
|
|
self.hass, remote.DOMAIN, {"remote": {"platform": "demo"}}
|
|
|
|
)
|
2016-12-01 20:48:08 +00:00
|
|
|
|
|
|
|
# pylint: disable=invalid-name
|
|
|
|
def tearDown(self):
|
|
|
|
"""Stop down everything that was started."""
|
|
|
|
self.hass.stop()
|
|
|
|
|
|
|
|
def test_methods(self):
|
2017-08-01 03:52:39 +00:00
|
|
|
"""Test if services call the entity methods as expected."""
|
2018-09-26 16:02:05 +00:00
|
|
|
common.turn_on(self.hass, entity_id=ENTITY_ID)
|
2016-12-01 20:48:08 +00:00
|
|
|
self.hass.block_till_done()
|
2017-08-01 03:52:39 +00:00
|
|
|
state = self.hass.states.get(ENTITY_ID)
|
2018-10-24 10:10:05 +00:00
|
|
|
assert state.state == STATE_ON
|
2016-12-01 20:48:08 +00:00
|
|
|
|
2018-09-26 16:02:05 +00:00
|
|
|
common.turn_off(self.hass, entity_id=ENTITY_ID)
|
2016-12-01 20:48:08 +00:00
|
|
|
self.hass.block_till_done()
|
2017-08-01 03:52:39 +00:00
|
|
|
state = self.hass.states.get(ENTITY_ID)
|
2018-10-24 10:10:05 +00:00
|
|
|
assert state.state == STATE_OFF
|
2016-12-01 20:48:08 +00:00
|
|
|
|
2018-09-26 16:02:05 +00:00
|
|
|
common.turn_on(self.hass, entity_id=ENTITY_ID)
|
2016-12-01 20:48:08 +00:00
|
|
|
self.hass.block_till_done()
|
2017-08-01 03:52:39 +00:00
|
|
|
state = self.hass.states.get(ENTITY_ID)
|
2018-10-24 10:10:05 +00:00
|
|
|
assert state.state == STATE_ON
|
2016-12-01 20:48:08 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
common.send_command(self.hass, "test", entity_id=ENTITY_ID)
|
2017-08-01 03:52:39 +00:00
|
|
|
self.hass.block_till_done()
|
|
|
|
state = self.hass.states.get(ENTITY_ID)
|
2019-06-05 09:32:59 +00:00
|
|
|
assert state.attributes == {
|
2019-07-31 19:25:30 +00:00
|
|
|
"friendly_name": "Remote One",
|
|
|
|
"last_command_sent": "test",
|
|
|
|
"supported_features": 0,
|
2019-06-05 09:32:59 +00:00
|
|
|
}
|