hass-core/tests/components/remote/test_demo.py
Martin Hjelmare 33663f9502 Clean up remote component (#8728)
* Clean up remote component

* Don't have device be required in send_command service and method.
* Don't have entity_id be required in the base service schema.
* Don't always add activity in the data dict for a service call.
* Update harmony remote platform according to new service schema.
* Remove not needed properties and attributes from the Kira remote
  platform.
* Add send_command method to demo platform.
* Add tests and remove duplicate tests.

* Break out required argument as positional argument
2017-07-31 20:52:39 -07:00

51 lines
1.7 KiB
Python
Executable file

"""The tests for the demo remote component."""
# pylint: disable=protected-access
import unittest
from homeassistant.setup import setup_component
import homeassistant.components.remote as remote
from homeassistant.const import STATE_ON, STATE_OFF
from tests.common import get_test_home_assistant
ENTITY_ID = 'remote.remote_one'
class TestDemoRemote(unittest.TestCase):
"""Test the demo remote."""
# pylint: disable=invalid-name
def setUp(self):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.assertTrue(setup_component(self.hass, remote.DOMAIN, {'remote': {
'platform': 'demo',
}}))
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down everything that was started."""
self.hass.stop()
def test_methods(self):
"""Test if services call the entity methods as expected."""
remote.turn_on(self.hass, entity_id=ENTITY_ID)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ID)
self.assertEqual(state.state, STATE_ON)
remote.turn_off(self.hass, entity_id=ENTITY_ID)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ID)
self.assertEqual(state.state, STATE_OFF)
remote.turn_on(self.hass, entity_id=ENTITY_ID)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ID)
self.assertEqual(state.state, STATE_ON)
remote.send_command(self.hass, 'test', entity_id=ENTITY_ID)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ID)
self.assertEqual(
state.attributes,
{'friendly_name': 'Remote One', 'last_command_sent': 'test'})