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