hass-core/tests/components/remote/test_kira.py
everix1992 3638b21bcb Added new commands and functionality to the harmony remote component. (#7113)
* Added new commands and functionality to the harmony remote component.

-This includes the ability to optionally specify a number of times to repeat a specific command, such as pressing the volume button multiple times.
-Also added a new command that allows you to send multiple commands to the harmony at once, such as sending a set of channel numbers.
-Updated the unit tests for these changes.

* Fix flake8 coding violations

* Remove send_commands command and make send_command handle a single or list of commands

* Remove send_commands tests

* Update itach and kira remotes for new send_command structure. Fix pyharmony version in requirements_all.txt

* Fix incorrect variable name

* Fix a couple minor issues with remote tests
2017-05-23 17:00:52 -07:00

57 lines
1.6 KiB
Python

"""The tests for Kira sensor platform."""
import unittest
from unittest.mock import MagicMock
from homeassistant.components.remote import kira as kira
from tests.common import get_test_home_assistant
SERVICE_SEND_COMMAND = 'send_command'
TEST_CONFIG = {kira.DOMAIN: {
'devices': [{'host': '127.0.0.1',
'port': 17324}]}}
DISCOVERY_INFO = {
'name': 'kira',
'device': 'kira'
}
class TestKiraSensor(unittest.TestCase):
"""Tests the Kira Sensor platform."""
# pylint: disable=invalid-name
DEVICES = []
def add_devices(self, devices):
"""Mock add devices."""
for device in devices:
self.DEVICES.append(device)
def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.mock_kira = MagicMock()
self.hass.data[kira.DOMAIN] = {kira.CONF_REMOTE: {}}
self.hass.data[kira.DOMAIN][kira.CONF_REMOTE]['kira'] = self.mock_kira
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
def test_service_call(self):
"""Test Kira's ability to send commands."""
kira.setup_platform(self.hass, TEST_CONFIG, self.add_devices,
DISCOVERY_INFO)
assert len(self.DEVICES) == 1
remote = self.DEVICES[0]
assert remote.name == 'kira'
command = ["FAKE_COMMAND"]
device = "FAKE_DEVICE"
commandTuple = (command[0], device)
remote.send_command(device=device, command=command)
self.mock_kira.sendCode.assert_called_with(commandTuple)