Merge remote-tracking branch 'upstream/dev' into igd
This commit is contained in:
commit
3db766e2ec
974 files changed
+6103
-3081
No files matched your search
@@ -32,9 +32,9 @@ class TestAlarmControlPanelManual(unittest.TestCase):
|
||||
def test_setup_demo_platform(self):
|
||||
"""Test setup."""
|
||||
mock = MagicMock()
|
||||
add_devices = mock.MagicMock()
|
||||
demo.setup_platform(self.hass, {}, add_devices)
|
||||
self.assertEqual(add_devices.call_count, 1)
|
||||
add_entities = mock.MagicMock()
|
||||
demo.setup_platform(self.hass, {}, add_entities)
|
||||
self.assertEqual(add_entities.call_count, 1)
|
||||
|
||||
def test_arm_home_no_pending(self):
|
||||
"""Test arm home method."""
|
||||
|
||||
@@ -54,7 +54,7 @@ def test_setup_platform(hass):
|
||||
|
||||
yield from spc.async_setup_platform(hass=hass,
|
||||
config={},
|
||||
async_add_devices=add_entities,
|
||||
async_add_entities=add_entities,
|
||||
discovery_info=areas)
|
||||
|
||||
assert len(added_entities) == 2
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
"""Tests for the mfa setup flow."""
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.auth import auth_manager_from_config
|
||||
from homeassistant.components.auth import mfa_setup_flow
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockUser, CLIENT_ID, ensure_auth_manager_loaded
|
||||
|
||||
|
||||
async def test_ws_setup_depose_mfa(hass, hass_ws_client):
|
||||
"""Test set up mfa module for current user."""
|
||||
hass.auth = await auth_manager_from_config(
|
||||
hass, provider_configs=[{
|
||||
'type': 'insecure_example',
|
||||
'users': [{
|
||||
'username': 'test-user',
|
||||
'password': 'test-pass',
|
||||
'name': 'Test Name',
|
||||
}]
|
||||
}], module_configs=[{
|
||||
'type': 'insecure_example',
|
||||
'id': 'example_module',
|
||||
'data': [{'user_id': 'mock-user', 'pin': '123456'}]
|
||||
}])
|
||||
ensure_auth_manager_loaded(hass.auth)
|
||||
await async_setup_component(hass, 'auth', {'http': {}})
|
||||
|
||||
user = MockUser(id='mock-user').add_to_hass(hass)
|
||||
cred = await hass.auth.auth_providers[0].async_get_or_create_credentials(
|
||||
{'username': 'test-user'})
|
||||
await hass.auth.async_link_user(user, cred)
|
||||
refresh_token = await hass.auth.async_create_refresh_token(user, CLIENT_ID)
|
||||
access_token = hass.auth.async_create_access_token(refresh_token)
|
||||
|
||||
client = await hass_ws_client(hass, access_token)
|
||||
|
||||
await client.send_json({
|
||||
'id': 10,
|
||||
'type': mfa_setup_flow.WS_TYPE_SETUP_MFA,
|
||||
})
|
||||
|
||||
result = await client.receive_json()
|
||||
assert result['id'] == 10
|
||||
assert result['success'] is False
|
||||
assert result['error']['code'] == 'no_module'
|
||||
|
||||
await client.send_json({
|
||||
'id': 11,
|
||||
'type': mfa_setup_flow.WS_TYPE_SETUP_MFA,
|
||||
'mfa_module_id': 'example_module',
|
||||
})
|
||||
|
||||
result = await client.receive_json()
|
||||
assert result['id'] == 11
|
||||
assert result['success']
|
||||
|
||||
flow = result['result']
|
||||
assert flow['type'] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert flow['handler'] == 'example_module'
|
||||
assert flow['step_id'] == 'init'
|
||||
assert flow['data_schema'][0] == {'type': 'string', 'name': 'pin'}
|
||||
|
||||
await client.send_json({
|
||||
'id': 12,
|
||||
'type': mfa_setup_flow.WS_TYPE_SETUP_MFA,
|
||||
'flow_id': flow['flow_id'],
|
||||
'user_input': {'pin': '654321'},
|
||||
})
|
||||
|
||||
result = await client.receive_json()
|
||||
assert result['id'] == 12
|
||||
assert result['success']
|
||||
|
||||
flow = result['result']
|
||||
assert flow['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert flow['handler'] == 'example_module'
|
||||
assert flow['data']['result'] is None
|
||||
|
||||
await client.send_json({
|
||||
'id': 13,
|
||||
'type': mfa_setup_flow.WS_TYPE_DEPOSE_MFA,
|
||||
'mfa_module_id': 'invalid_id',
|
||||
})
|
||||
|
||||
result = await client.receive_json()
|
||||
assert result['id'] == 13
|
||||
assert result['success'] is False
|
||||
assert result['error']['code'] == 'disable_failed'
|
||||
|
||||
await client.send_json({
|
||||
'id': 14,
|
||||
'type': mfa_setup_flow.WS_TYPE_DEPOSE_MFA,
|
||||
'mfa_module_id': 'example_module',
|
||||
})
|
||||
|
||||
result = await client.receive_json()
|
||||
assert result['id'] == 14
|
||||
assert result['success']
|
||||
assert result['result'] == 'done'
|
||||
@@ -45,17 +45,17 @@ class TestNX584SensorSetup(unittest.TestCase):
|
||||
@mock.patch('homeassistant.components.binary_sensor.nx584.NX584ZoneSensor')
|
||||
def test_setup_defaults(self, mock_nx, mock_watcher):
|
||||
"""Test the setup with no configuration."""
|
||||
add_devices = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
config = {
|
||||
'host': nx584.DEFAULT_HOST,
|
||||
'port': nx584.DEFAULT_PORT,
|
||||
'exclude_zones': [],
|
||||
'zone_types': {},
|
||||
}
|
||||
self.assertTrue(nx584.setup_platform(self.hass, config, add_devices))
|
||||
self.assertTrue(nx584.setup_platform(self.hass, config, add_entities))
|
||||
mock_nx.assert_has_calls(
|
||||
[mock.call(zone, 'opening') for zone in self.fake_zones])
|
||||
self.assertTrue(add_devices.called)
|
||||
self.assertTrue(add_entities.called)
|
||||
self.assertEqual(nx584_client.Client.call_count, 1)
|
||||
self.assertEqual(
|
||||
nx584_client.Client.call_args, mock.call('http://localhost:5007')
|
||||
@@ -71,13 +71,13 @@ class TestNX584SensorSetup(unittest.TestCase):
|
||||
'exclude_zones': [2],
|
||||
'zone_types': {3: 'motion'},
|
||||
}
|
||||
add_devices = mock.MagicMock()
|
||||
self.assertTrue(nx584.setup_platform(self.hass, config, add_devices))
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertTrue(nx584.setup_platform(self.hass, config, add_entities))
|
||||
mock_nx.assert_has_calls([
|
||||
mock.call(self.fake_zones[0], 'opening'),
|
||||
mock.call(self.fake_zones[2], 'motion'),
|
||||
])
|
||||
self.assertTrue(add_devices.called)
|
||||
self.assertTrue(add_entities.called)
|
||||
self.assertEqual(nx584_client.Client.call_count, 1)
|
||||
self.assertEqual(
|
||||
nx584_client.Client.call_args, mock.call('http://foo:123')
|
||||
@@ -120,9 +120,9 @@ class TestNX584SensorSetup(unittest.TestCase):
|
||||
def test_setup_no_zones(self):
|
||||
"""Test the setup with no zones."""
|
||||
nx584_client.Client.return_value.list_zones.return_value = []
|
||||
add_devices = mock.MagicMock()
|
||||
self.assertTrue(nx584.setup_platform(self.hass, {}, add_devices))
|
||||
self.assertFalse(add_devices.called)
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertTrue(nx584.setup_platform(self.hass, {}, add_entities))
|
||||
self.assertFalse(add_entities.called)
|
||||
|
||||
|
||||
class TestNX584ZoneSensor(unittest.TestCase):
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestRingBinarySensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, action):
|
||||
def add_entities(self, devices, action):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -58,7 +58,7 @@ class TestRingBinarySensorSetup(unittest.TestCase):
|
||||
base_ring.setup(self.hass, VALID_CONFIG)
|
||||
ring.setup_platform(self.hass,
|
||||
self.config,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
for device in self.DEVICES:
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestSleepIQBinarySensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -45,7 +45,7 @@ class TestSleepIQBinarySensorSetup(unittest.TestCase):
|
||||
|
||||
sleepiq.setup_platform(self.hass,
|
||||
self.config,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
MagicMock())
|
||||
self.assertEqual(2, len(self.DEVICES))
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ def test_setup_platform(hass):
|
||||
|
||||
yield from spc.async_setup_platform(hass=hass,
|
||||
config={},
|
||||
async_add_devices=add_entities,
|
||||
async_add_entities=add_entities,
|
||||
discovery_info=zones)
|
||||
|
||||
assert len(added_entities) == 3
|
||||
|
||||
@@ -38,13 +38,13 @@ class TestTCPBinarySensor(unittest.TestCase):
|
||||
|
||||
@patch('homeassistant.components.sensor.tcp.TcpSensor.update')
|
||||
def test_setup_platform_devices(self, mock_update):
|
||||
"""Check the supplied config and call add_devices with sensor."""
|
||||
add_devices = Mock()
|
||||
ret = bin_tcp.setup_platform(None, test_tcp.TEST_CONFIG, add_devices)
|
||||
"""Check the supplied config and call add_entities with sensor."""
|
||||
add_entities = Mock()
|
||||
ret = bin_tcp.setup_platform(None, test_tcp.TEST_CONFIG, add_entities)
|
||||
assert ret is None
|
||||
assert add_devices.called
|
||||
assert add_entities.called
|
||||
assert isinstance(
|
||||
add_devices.call_args[0][0][0], bin_tcp.TcpBinarySensor)
|
||||
add_entities.call_args[0][0][0], bin_tcp.TcpBinarySensor)
|
||||
|
||||
@patch('homeassistant.components.sensor.tcp.TcpSensor.update')
|
||||
def test_is_on_true(self, mock_update):
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestVultrBinarySensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, action):
|
||||
def add_entities(self, devices, action):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -71,7 +71,7 @@ class TestVultrBinarySensorSetup(unittest.TestCase):
|
||||
for config in self.configs:
|
||||
vultr.setup_platform(self.hass,
|
||||
config,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
self.assertEqual(len(self.DEVICES), 3)
|
||||
@@ -147,7 +147,7 @@ class TestVultrBinarySensorSetup(unittest.TestCase):
|
||||
|
||||
no_subs_setup = vultr.setup_platform(self.hass,
|
||||
bad_conf,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
self.assertFalse(no_subs_setup)
|
||||
@@ -159,7 +159,7 @@ class TestVultrBinarySensorSetup(unittest.TestCase):
|
||||
|
||||
wrong_subs_setup = vultr.setup_platform(self.hass,
|
||||
bad_conf,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
self.assertFalse(wrong_subs_setup)
|
||||
@@ -56,7 +56,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
honeywell.PLATFORM_SCHEMA(bad_region_config)
|
||||
|
||||
hass = mock.MagicMock()
|
||||
add_devices = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
|
||||
locations = [
|
||||
mock.MagicMock(),
|
||||
@@ -69,7 +69,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
locations[0].devices_by_id.values.return_value = devices_1
|
||||
locations[1].devices_by_id.values.return_value = devices_2
|
||||
|
||||
result = honeywell.setup_platform(hass, config, add_devices)
|
||||
result = honeywell.setup_platform(hass, config, add_entities)
|
||||
self.assertTrue(result)
|
||||
self.assertEqual(mock_sc.call_count, 1)
|
||||
self.assertEqual(mock_sc.call_args, mock.call('user', 'pass'))
|
||||
@@ -86,7 +86,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
def test_setup_us_failures(self, mock_sc):
|
||||
"""Test the US setup."""
|
||||
hass = mock.MagicMock()
|
||||
add_devices = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
config = {
|
||||
CONF_USERNAME: 'user',
|
||||
CONF_PASSWORD: 'pass',
|
||||
@@ -94,14 +94,14 @@ class TestHoneywell(unittest.TestCase):
|
||||
}
|
||||
|
||||
mock_sc.side_effect = somecomfort.AuthError
|
||||
result = honeywell.setup_platform(hass, config, add_devices)
|
||||
result = honeywell.setup_platform(hass, config, add_entities)
|
||||
self.assertFalse(result)
|
||||
self.assertFalse(add_devices.called)
|
||||
self.assertFalse(add_entities.called)
|
||||
|
||||
mock_sc.side_effect = somecomfort.SomeComfortError
|
||||
result = honeywell.setup_platform(hass, config, add_devices)
|
||||
result = honeywell.setup_platform(hass, config, add_entities)
|
||||
self.assertFalse(result)
|
||||
self.assertFalse(add_devices.called)
|
||||
self.assertFalse(add_entities.called)
|
||||
|
||||
@mock.patch('somecomfort.SomeComfort')
|
||||
@mock.patch('homeassistant.components.climate.'
|
||||
@@ -136,9 +136,9 @@ class TestHoneywell(unittest.TestCase):
|
||||
}
|
||||
mock_sc.return_value = mock.MagicMock(locations_by_id=locations)
|
||||
hass = mock.MagicMock()
|
||||
add_devices = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertEqual(True,
|
||||
honeywell.setup_platform(hass, config, add_devices))
|
||||
honeywell.setup_platform(hass, config, add_entities))
|
||||
|
||||
return mock_ht.call_args_list, mock_sc
|
||||
|
||||
@@ -185,8 +185,8 @@ class TestHoneywell(unittest.TestCase):
|
||||
mock_evo.return_value.temperatures.return_value = [
|
||||
{'id': 'foo'}, {'id': 'bar'}]
|
||||
hass = mock.MagicMock()
|
||||
add_devices = mock.MagicMock()
|
||||
self.assertTrue(honeywell.setup_platform(hass, config, add_devices))
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertTrue(honeywell.setup_platform(hass, config, add_entities))
|
||||
self.assertEqual(mock_evo.call_count, 1)
|
||||
self.assertEqual(mock_evo.call_args, mock.call('user', 'pass'))
|
||||
self.assertEqual(mock_evo.return_value.temperatures.call_count, 1)
|
||||
@@ -198,7 +198,7 @@ class TestHoneywell(unittest.TestCase):
|
||||
mock.call(mock_evo.return_value, 'foo', True, 20.0),
|
||||
mock.call(mock_evo.return_value, 'bar', False, 20.0),
|
||||
])
|
||||
self.assertEqual(2, add_devices.call_count)
|
||||
self.assertEqual(2, add_entities.call_count)
|
||||
|
||||
@mock.patch('evohomeclient.EvohomeClient')
|
||||
@mock.patch('homeassistant.components.climate.honeywell.'
|
||||
@@ -217,8 +217,8 @@ class TestHoneywell(unittest.TestCase):
|
||||
honeywell.DEFAULT_AWAY_TEMPERATURE
|
||||
|
||||
hass = mock.MagicMock()
|
||||
add_devices = mock.MagicMock()
|
||||
self.assertTrue(honeywell.setup_platform(hass, config, add_devices))
|
||||
add_entities = mock.MagicMock()
|
||||
self.assertTrue(honeywell.setup_platform(hass, config, add_entities))
|
||||
mock_round.assert_has_calls([
|
||||
mock.call(mock_evo.return_value, 'foo', True, 16),
|
||||
mock.call(mock_evo.return_value, 'bar', False, 16),
|
||||
@@ -251,9 +251,9 @@ class TestHoneywell(unittest.TestCase):
|
||||
honeywell.CONF_REGION: 'eu',
|
||||
}
|
||||
mock_evo.return_value.temperatures.side_effect = socket.error
|
||||
add_devices = mock.MagicMock()
|
||||
add_entities = mock.MagicMock()
|
||||
hass = mock.MagicMock()
|
||||
self.assertFalse(honeywell.setup_platform(hass, config, add_devices))
|
||||
self.assertFalse(honeywell.setup_platform(hass, config, add_entities))
|
||||
|
||||
|
||||
class TestHoneywellRound(unittest.TestCase):
|
||||
|
||||
@@ -76,11 +76,11 @@ class TestMelissa(unittest.TestCase):
|
||||
self.hass.data[DATA_MELISSA] = self.api
|
||||
|
||||
config = {}
|
||||
add_devices = Mock()
|
||||
add_entities = Mock()
|
||||
discovery_info = {}
|
||||
|
||||
melissa.setup_platform(self.hass, config, add_devices, discovery_info)
|
||||
add_devices.assert_called_once_with(thermostats)
|
||||
melissa.setup_platform(self.hass, config, add_entities, discovery_info)
|
||||
add_entities.assert_called_once_with(thermostats)
|
||||
|
||||
def test_get_name(self):
|
||||
"""Test name property."""
|
||||
|
||||
@@ -67,11 +67,11 @@ class TestNuHeat(unittest.TestCase):
|
||||
self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"])
|
||||
|
||||
config = {}
|
||||
add_devices = Mock()
|
||||
add_entities = Mock()
|
||||
discovery_info = {}
|
||||
|
||||
nuheat.setup_platform(self.hass, config, add_devices, discovery_info)
|
||||
add_devices.assert_called_once_with(thermostats, True)
|
||||
nuheat.setup_platform(self.hass, config, add_entities, discovery_info)
|
||||
add_entities.assert_called_once_with(thermostats, True)
|
||||
|
||||
@patch("homeassistant.components.climate.nuheat.NuHeatThermostat")
|
||||
def test_resume_program_service(self, mocked_thermostat):
|
||||
|
||||
@@ -7,6 +7,16 @@ from homeassistant.components import deconz
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
CONFIG = {
|
||||
"config": {
|
||||
"bridgeid": "0123456789ABCDEF",
|
||||
"mac": "12:34:56:78:90:ab",
|
||||
"modelid": "deCONZ",
|
||||
"name": "Phoscon",
|
||||
"swversion": "2.05.35"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async def test_config_with_host_passed_to_config_entry(hass):
|
||||
"""Test that configured options for a host are loaded via config entry."""
|
||||
@@ -93,8 +103,11 @@ async def test_setup_entry_successful(hass):
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
||||
with patch.object(hass, 'async_create_task') as mock_add_job, \
|
||||
patch.object(hass, 'config_entries') as mock_config_entries, \
|
||||
patch('pydeconz.DeconzSession.async_load_parameters',
|
||||
return_value=mock_coro(True)):
|
||||
patch('pydeconz.DeconzSession.async_get_state',
|
||||
return_value=mock_coro(CONFIG)), \
|
||||
patch('pydeconz.DeconzSession.start', return_value=True), \
|
||||
patch('homeassistant.helpers.device_registry.async_get_registry',
|
||||
return_value=mock_coro(Mock())):
|
||||
assert await deconz.async_setup_entry(hass, entry) is True
|
||||
assert hass.data[deconz.DOMAIN]
|
||||
assert hass.data[deconz.DATA_DECONZ_ID] == {}
|
||||
@@ -117,10 +130,15 @@ async def test_unload_entry(hass):
|
||||
"""Test being able to unload an entry."""
|
||||
entry = Mock()
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
||||
with patch('pydeconz.DeconzSession.async_load_parameters',
|
||||
return_value=mock_coro(True)):
|
||||
entry.async_unload.return_value = mock_coro(True)
|
||||
deconzmock = Mock()
|
||||
deconzmock.async_load_parameters.return_value = mock_coro(True)
|
||||
deconzmock.sensors = {}
|
||||
with patch('pydeconz.DeconzSession', return_value=deconzmock):
|
||||
assert await deconz.async_setup_entry(hass, entry) is True
|
||||
|
||||
assert deconz.DATA_DECONZ_EVENT in hass.data
|
||||
|
||||
hass.data[deconz.DATA_DECONZ_EVENT].append(Mock())
|
||||
hass.data[deconz.DATA_DECONZ_ID] = {'id': 'deconzid'}
|
||||
assert await deconz.async_unload_entry(hass, entry)
|
||||
@@ -132,6 +150,9 @@ async def test_unload_entry(hass):
|
||||
|
||||
async def test_add_new_device(hass):
|
||||
"""Test adding a new device generates a signal for platforms."""
|
||||
entry = Mock()
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80,
|
||||
'api_key': '1234567890ABCDEF', 'allow_clip_sensor': False}
|
||||
new_event = {
|
||||
"t": "event",
|
||||
"e": "added",
|
||||
@@ -147,11 +168,10 @@ async def test_add_new_device(hass):
|
||||
"type": "ZHASwitch"
|
||||
}
|
||||
}
|
||||
entry = Mock()
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
||||
with patch.object(deconz, 'async_dispatcher_send') as mock_dispatch_send, \
|
||||
patch('pydeconz.DeconzSession.async_load_parameters',
|
||||
return_value=mock_coro(True)):
|
||||
patch('pydeconz.DeconzSession.async_get_state',
|
||||
return_value=mock_coro(CONFIG)), \
|
||||
patch('pydeconz.DeconzSession.start', return_value=True):
|
||||
assert await deconz.async_setup_entry(hass, entry) is True
|
||||
hass.data[deconz.DOMAIN].async_event_handler(new_event)
|
||||
await hass.async_block_till_done()
|
||||
@@ -162,15 +182,16 @@ async def test_add_new_device(hass):
|
||||
async def test_add_new_remote(hass):
|
||||
"""Test new added device creates a new remote."""
|
||||
entry = Mock()
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80, 'api_key': '1234567890ABCDEF'}
|
||||
entry.data = {'host': '1.2.3.4', 'port': 80,
|
||||
'api_key': '1234567890ABCDEF', 'allow_clip_sensor': False}
|
||||
remote = Mock()
|
||||
remote.name = 'name'
|
||||
remote.type = 'ZHASwitch'
|
||||
remote.register_async_callback = Mock()
|
||||
with patch('pydeconz.DeconzSession.async_load_parameters',
|
||||
return_value=mock_coro(True)):
|
||||
with patch('pydeconz.DeconzSession.async_get_state',
|
||||
return_value=mock_coro(CONFIG)), \
|
||||
patch('pydeconz.DeconzSession.start', return_value=True):
|
||||
assert await deconz.async_setup_entry(hass, entry) is True
|
||||
|
||||
async_dispatcher_send(hass, 'deconz_new_sensor', [remote])
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.data[deconz.DATA_DECONZ_EVENT]) == 1
|
||||
@@ -185,8 +206,9 @@ async def test_do_not_allow_clip_sensor(hass):
|
||||
remote.name = 'name'
|
||||
remote.type = 'CLIPSwitch'
|
||||
remote.register_async_callback = Mock()
|
||||
with patch('pydeconz.DeconzSession.async_load_parameters',
|
||||
return_value=mock_coro(True)):
|
||||
with patch('pydeconz.DeconzSession.async_get_state',
|
||||
return_value=mock_coro(CONFIG)), \
|
||||
patch('pydeconz.DeconzSession.start', return_value=True):
|
||||
assert await deconz.async_setup_entry(hass, entry) is True
|
||||
|
||||
async_dispatcher_send(hass, 'deconz_new_sensor', [remote])
|
||||
|
||||
@@ -78,9 +78,9 @@ class DysonTest(unittest.TestCase):
|
||||
def test_setup_component_with_no_devices(self):
|
||||
"""Test setup component with no devices."""
|
||||
self.hass.data[dyson.DYSON_DEVICES] = []
|
||||
add_devices = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, None, add_devices)
|
||||
add_devices.assert_called_with([])
|
||||
add_entities = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, None, add_entities)
|
||||
add_entities.assert_called_with([])
|
||||
|
||||
def test_setup_component(self):
|
||||
"""Test setup component with devices."""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Test Hue setup process."""
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import hue
|
||||
@@ -145,9 +145,21 @@ async def test_config_passed_to_config_entry(hass):
|
||||
'host': '0.0.0.0',
|
||||
})
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch.object(hue, 'HueBridge') as mock_bridge:
|
||||
mock_registry = Mock()
|
||||
with patch.object(hue, 'HueBridge') as mock_bridge, \
|
||||
patch('homeassistant.helpers.device_registry.async_get_registry',
|
||||
return_value=mock_coro(mock_registry)):
|
||||
mock_bridge.return_value.async_setup.return_value = mock_coro(True)
|
||||
mock_bridge.return_value.api.config = Mock(
|
||||
mac='mock-mac',
|
||||
bridgeid='mock-bridgeid',
|
||||
raw={
|
||||
'modelid': 'mock-modelid',
|
||||
'swversion': 'mock-swversion',
|
||||
}
|
||||
)
|
||||
# Can't set name via kwargs
|
||||
mock_bridge.return_value.api.config.name = 'mock-name'
|
||||
assert await async_setup_component(hass, hue.DOMAIN, {
|
||||
hue.DOMAIN: {
|
||||
hue.CONF_BRIDGES: {
|
||||
@@ -168,6 +180,21 @@ async def test_config_passed_to_config_entry(hass):
|
||||
assert p_allow_unreachable is True
|
||||
assert p_allow_groups is False
|
||||
|
||||
assert len(mock_registry.mock_calls) == 1
|
||||
assert mock_registry.mock_calls[0][2] == {
|
||||
'config_entry': entry.entry_id,
|
||||
'connections': {
|
||||
('mac', 'mock-mac')
|
||||
},
|
||||
'identifiers': {
|
||||
('hue', 'mock-bridgeid')
|
||||
},
|
||||
'manufacturer': 'Signify',
|
||||
'name': 'mock-name',
|
||||
'model': 'mock-modelid',
|
||||
'sw_version': 'mock-swversion'
|
||||
}
|
||||
|
||||
|
||||
async def test_unload_entry(hass):
|
||||
"""Test being able to unload an entry."""
|
||||
@@ -176,8 +203,11 @@ async def test_unload_entry(hass):
|
||||
})
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch.object(hue, 'HueBridge') as mock_bridge:
|
||||
with patch.object(hue, 'HueBridge') as mock_bridge, \
|
||||
patch('homeassistant.helpers.device_registry.async_get_registry',
|
||||
return_value=mock_coro(Mock())):
|
||||
mock_bridge.return_value.async_setup.return_value = mock_coro(True)
|
||||
mock_bridge.return_value.api.config = Mock()
|
||||
assert await async_setup_component(hass, hue.DOMAIN, {}) is True
|
||||
|
||||
assert len(mock_bridge.return_value.mock_calls) == 1
|
||||
|
||||
@@ -346,13 +346,13 @@ async def test_service_calls(hass):
|
||||
|
||||
async def test_invalid_service_calls(hass):
|
||||
"""Test invalid service call arguments get discarded."""
|
||||
add_devices = MagicMock()
|
||||
add_entities = MagicMock()
|
||||
await group.async_setup_platform(hass, {
|
||||
'entities': ['light.test1', 'light.test2']
|
||||
}, add_devices)
|
||||
}, add_entities)
|
||||
|
||||
assert add_devices.call_count == 1
|
||||
grouped_light = add_devices.call_args[0][0][0]
|
||||
assert add_entities.call_count == 1
|
||||
grouped_light = add_entities.call_args[0][0][0]
|
||||
grouped_light.hass = hass
|
||||
|
||||
with asynctest.patch.object(hass.services, 'async_call') as mock_call:
|
||||
|
||||
@@ -51,13 +51,13 @@ async def async_setup_cast(hass, config=None, discovery_info=None):
|
||||
"""Set up the cast platform."""
|
||||
if config is None:
|
||||
config = {}
|
||||
add_devices = Mock()
|
||||
add_entities = Mock()
|
||||
|
||||
await cast.async_setup_platform(hass, config, add_devices,
|
||||
await cast.async_setup_platform(hass, config, add_entities,
|
||||
discovery_info=discovery_info)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
return add_devices
|
||||
return add_entities
|
||||
|
||||
|
||||
async def async_setup_cast_internal_discovery(hass, config=None,
|
||||
@@ -67,7 +67,7 @@ async def async_setup_cast_internal_discovery(hass, config=None,
|
||||
|
||||
with patch('pychromecast.start_discovery',
|
||||
return_value=(listener, None)) as start_discovery:
|
||||
add_devices = await async_setup_cast(hass, config, discovery_info)
|
||||
add_entities = await async_setup_cast(hass, config, discovery_info)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -77,10 +77,13 @@ async def async_setup_cast_internal_discovery(hass, config=None,
|
||||
|
||||
def discover_chromecast(service_name: str, info: ChromecastInfo) -> None:
|
||||
"""Discover a chromecast device."""
|
||||
listener.services[service_name] = attr.astuple(info)
|
||||
listener.services[service_name] = (
|
||||
info.host, info.port, info.uuid, info.model_name,
|
||||
info.friendly_name
|
||||
)
|
||||
discovery_callback(service_name)
|
||||
|
||||
return discover_chromecast, add_devices
|
||||
return discover_chromecast, add_entities
|
||||
|
||||
|
||||
async def async_setup_media_player_cast(hass: HomeAssistantType,
|
||||
@@ -152,8 +155,7 @@ async def test_internal_discovery_callback_only_generates_once(hass):
|
||||
discover_cast('the-service', info)
|
||||
await hass.async_block_till_done()
|
||||
discover = signal.mock_calls[0][1][0]
|
||||
# attr's __eq__ somehow breaks here, use tuples instead
|
||||
assert attr.astuple(discover) == attr.astuple(info)
|
||||
assert discover == info
|
||||
signal.reset_mock()
|
||||
|
||||
# discovering it a second time shouldn't
|
||||
@@ -183,8 +185,7 @@ async def test_internal_discovery_callback_fill_out(hass):
|
||||
|
||||
# when called with incomplete info, it should use HTTP to get missing
|
||||
discover = signal.mock_calls[0][1][0]
|
||||
# attr's __eq__ somehow breaks here, use tuples instead
|
||||
assert attr.astuple(discover) == attr.astuple(full_info)
|
||||
assert discover == full_info
|
||||
|
||||
|
||||
async def test_create_cast_device_without_uuid(hass):
|
||||
@@ -214,30 +215,30 @@ async def test_normal_chromecast_not_starting_discovery(hass):
|
||||
with patch('homeassistant.components.media_player.cast.'
|
||||
'_setup_internal_discovery') as setup_discovery:
|
||||
# normal (non-group) chromecast shouldn't start discovery.
|
||||
add_devices = await async_setup_cast(hass, {'host': 'host1'})
|
||||
add_entities = await async_setup_cast(hass, {'host': 'host1'})
|
||||
await hass.async_block_till_done()
|
||||
assert add_devices.call_count == 1
|
||||
assert add_entities.call_count == 1
|
||||
assert setup_discovery.call_count == 0
|
||||
|
||||
# Same entity twice
|
||||
add_devices = await async_setup_cast(hass, {'host': 'host1'})
|
||||
add_entities = await async_setup_cast(hass, {'host': 'host1'})
|
||||
await hass.async_block_till_done()
|
||||
assert add_devices.call_count == 0
|
||||
assert add_entities.call_count == 0
|
||||
assert setup_discovery.call_count == 0
|
||||
|
||||
hass.data[cast.ADDED_CAST_DEVICES_KEY] = set()
|
||||
add_devices = await async_setup_cast(
|
||||
add_entities = await async_setup_cast(
|
||||
hass, discovery_info={'host': 'host1', 'port': 8009})
|
||||
await hass.async_block_till_done()
|
||||
assert add_devices.call_count == 1
|
||||
assert add_entities.call_count == 1
|
||||
assert setup_discovery.call_count == 0
|
||||
|
||||
# group should start discovery.
|
||||
hass.data[cast.ADDED_CAST_DEVICES_KEY] = set()
|
||||
add_devices = await async_setup_cast(
|
||||
add_entities = await async_setup_cast(
|
||||
hass, discovery_info={'host': 'host1', 'port': 42})
|
||||
await hass.async_block_till_done()
|
||||
assert add_devices.call_count == 0
|
||||
assert add_entities.call_count == 0
|
||||
assert setup_discovery.call_count == 1
|
||||
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ class TestSamsungTv(unittest.TestCase):
|
||||
"""Testing setup of platform."""
|
||||
with mock.patch(
|
||||
'homeassistant.components.media_player.samsungtv.socket'):
|
||||
add_devices = mock.Mock()
|
||||
add_entities = mock.Mock()
|
||||
setup_platform(
|
||||
self.hass, WORKING_CONFIG, add_devices)
|
||||
self.hass, WORKING_CONFIG, add_entities)
|
||||
|
||||
@MockDependency('samsungctl')
|
||||
@MockDependency('wakeonlan')
|
||||
@@ -82,8 +82,8 @@ class TestSamsungTv(unittest.TestCase):
|
||||
"""Testing setup of platform with discovery."""
|
||||
with mock.patch(
|
||||
'homeassistant.components.media_player.samsungtv.socket'):
|
||||
add_devices = mock.Mock()
|
||||
setup_platform(self.hass, {}, add_devices,
|
||||
add_entities = mock.Mock()
|
||||
setup_platform(self.hass, {}, add_entities,
|
||||
discovery_info=DISCOVERY_INFO)
|
||||
|
||||
@MockDependency('samsungctl')
|
||||
@@ -94,11 +94,11 @@ class TestSamsungTv(unittest.TestCase):
|
||||
"""Testing setup of platform with no data."""
|
||||
with mock.patch(
|
||||
'homeassistant.components.media_player.samsungtv.socket'):
|
||||
add_devices = mock.Mock()
|
||||
setup_platform(self.hass, {}, add_devices,
|
||||
add_entities = mock.Mock()
|
||||
setup_platform(self.hass, {}, add_entities,
|
||||
discovery_info=None)
|
||||
mocked_warn.assert_called_once_with("Cannot determine device")
|
||||
add_devices.assert_not_called()
|
||||
add_entities.assert_not_called()
|
||||
|
||||
@mock.patch(
|
||||
'homeassistant.components.media_player.samsungtv.subprocess.Popen'
|
||||
|
||||
@@ -121,13 +121,13 @@ class SoCoMock():
|
||||
return
|
||||
|
||||
|
||||
def add_devices_factory(hass):
|
||||
def add_entities_factory(hass):
|
||||
"""Add devices factory."""
|
||||
def add_devices(devices, update_befor_add=False):
|
||||
def add_entities(devices, update_befor_add=False):
|
||||
"""Fake add device."""
|
||||
hass.data[sonos.DATA_SONOS].devices = devices
|
||||
|
||||
return add_devices
|
||||
return add_entities
|
||||
|
||||
|
||||
class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@@ -157,7 +157,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@mock.patch('socket.create_connection', side_effect=socket.error())
|
||||
def test_ensure_setup_discovery(self, *args):
|
||||
"""Test a single device using the autodiscovery provided by HASS."""
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass), {
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
|
||||
'host': '192.0.2.1'
|
||||
})
|
||||
|
||||
@@ -240,7 +240,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@mock.patch('socket.create_connection', side_effect=socket.error())
|
||||
def test_ensure_setup_sonos_discovery(self, *args):
|
||||
"""Test a single device using the autodiscovery provided by Sonos."""
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass))
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass))
|
||||
devices = list(self.hass.data[sonos.DATA_SONOS].devices)
|
||||
self.assertEqual(len(devices), 1)
|
||||
self.assertEqual(devices[0].name, 'Kitchen')
|
||||
@@ -250,7 +250,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@mock.patch.object(SoCoMock, 'set_sleep_timer')
|
||||
def test_sonos_set_sleep_timer(self, set_sleep_timerMock, *args):
|
||||
"""Ensuring soco methods called for sonos_set_sleep_timer service."""
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass), {
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
|
||||
'host': '192.0.2.1'
|
||||
})
|
||||
device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
|
||||
@@ -264,7 +264,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@mock.patch.object(SoCoMock, 'set_sleep_timer')
|
||||
def test_sonos_clear_sleep_timer(self, set_sleep_timerMock, *args):
|
||||
"""Ensuring soco methods called for sonos_clear_sleep_timer service."""
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass), {
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
|
||||
'host': '192.0.2.1'
|
||||
})
|
||||
device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
|
||||
@@ -278,7 +278,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@mock.patch('socket.create_connection', side_effect=socket.error())
|
||||
def test_set_alarm(self, soco_mock, alarm_mock, *args):
|
||||
"""Ensuring soco methods called for sonos_set_sleep_timer service."""
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass), {
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
|
||||
'host': '192.0.2.1'
|
||||
})
|
||||
device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
|
||||
@@ -308,7 +308,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
@mock.patch.object(soco.snapshot.Snapshot, 'snapshot')
|
||||
def test_sonos_snapshot(self, snapshotMock, *args):
|
||||
"""Ensuring soco methods called for sonos_snapshot service."""
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass), {
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
|
||||
'host': '192.0.2.1'
|
||||
})
|
||||
device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
|
||||
@@ -326,7 +326,7 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
||||
"""Ensuring soco methods called for sonos_restor service."""
|
||||
from soco.snapshot import Snapshot
|
||||
|
||||
sonos.setup_platform(self.hass, {}, add_devices_factory(self.hass), {
|
||||
sonos.setup_platform(self.hass, {}, add_entities_factory(self.hass), {
|
||||
'host': '192.0.2.1'
|
||||
})
|
||||
device = list(self.hass.data[sonos.DATA_SONOS].devices)[-1]
|
||||
|
||||
@@ -279,7 +279,7 @@ class TestMediaPlayer(unittest.TestCase):
|
||||
bad_config = {'platform': 'universal'}
|
||||
entities = []
|
||||
|
||||
def add_devices(new_entities):
|
||||
def add_entities(new_entities):
|
||||
"""Add devices to list."""
|
||||
for dev in new_entities:
|
||||
entities.append(dev)
|
||||
@@ -288,7 +288,7 @@ class TestMediaPlayer(unittest.TestCase):
|
||||
try:
|
||||
run_coroutine_threadsafe(
|
||||
universal.async_setup_platform(
|
||||
self.hass, validate_config(bad_config), add_devices),
|
||||
self.hass, validate_config(bad_config), add_entities),
|
||||
self.hass.loop).result()
|
||||
except MultipleInvalid:
|
||||
setup_ok = False
|
||||
@@ -297,7 +297,7 @@ class TestMediaPlayer(unittest.TestCase):
|
||||
|
||||
run_coroutine_threadsafe(
|
||||
universal.async_setup_platform(
|
||||
self.hass, validate_config(config), add_devices),
|
||||
self.hass, validate_config(config), add_entities),
|
||||
self.hass.loop).result()
|
||||
self.assertEqual(1, len(entities))
|
||||
self.assertEqual('test', entities[0].name)
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestKiraSensor(unittest.TestCase):
|
||||
# pylint: disable=invalid-name
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -42,7 +42,7 @@ class TestKiraSensor(unittest.TestCase):
|
||||
|
||||
def test_service_call(self):
|
||||
"""Test Kira's ability to send commands."""
|
||||
kira.setup_platform(self.hass, TEST_CONFIG, self.add_devices,
|
||||
kira.setup_platform(self.hass, TEST_CONFIG, self.add_entities,
|
||||
DISCOVERY_INFO)
|
||||
assert len(self.DEVICES) == 1
|
||||
remote = self.DEVICES[0]
|
||||
|
||||
@@ -64,14 +64,14 @@ def captured_sensor():
|
||||
|
||||
|
||||
class PlatformSetupFixture():
|
||||
"""Fixture for testing platform setup call to add_devices()."""
|
||||
"""Fixture for testing platform setup call to add_entities()."""
|
||||
|
||||
def __init__(self):
|
||||
"""Instantiate the platform setup fixture."""
|
||||
self.sensors = None
|
||||
self.update = False
|
||||
|
||||
def add_devices(self, sensors, update):
|
||||
def add_entities(self, sensors, update):
|
||||
"""Mock method for adding devices."""
|
||||
self.sensors = sensors
|
||||
self.update = update
|
||||
@@ -101,7 +101,7 @@ def mock_dispatch():
|
||||
|
||||
def test_setup_with_no_data(platform_setup, hass):
|
||||
"""Test setup_platform with no data."""
|
||||
arlo.setup_platform(hass, None, platform_setup.add_devices)
|
||||
arlo.setup_platform(hass, None, platform_setup.add_entities)
|
||||
assert platform_setup.sensors is None
|
||||
assert not platform_setup.update
|
||||
|
||||
@@ -132,7 +132,7 @@ def test_setup_with_valid_data(platform_setup, hass):
|
||||
})]
|
||||
})
|
||||
|
||||
arlo.setup_platform(hass, config, platform_setup.add_devices)
|
||||
arlo.setup_platform(hass, config, platform_setup.add_entities)
|
||||
assert len(platform_setup.sensors) == 8
|
||||
assert platform_setup.update
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestCanarySensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, action):
|
||||
def add_entities(self, devices, action):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -51,7 +51,7 @@ class TestCanarySensorSetup(unittest.TestCase):
|
||||
mock_location("Work", True, devices=[online_device_at_work]),
|
||||
]
|
||||
|
||||
canary.setup_platform(self.hass, self.config, self.add_devices, None)
|
||||
canary.setup_platform(self.hass, self.config, self.add_entities, None)
|
||||
|
||||
self.assertEqual(6, len(self.DEVICES))
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ class DysonTest(unittest.TestCase):
|
||||
def test_setup_component_with_no_devices(self):
|
||||
"""Test setup component with no devices."""
|
||||
self.hass.data[dyson.DYSON_DEVICES] = []
|
||||
add_devices = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, None, add_devices)
|
||||
add_devices.assert_called_with([])
|
||||
add_entities = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, None, add_entities)
|
||||
add_entities.assert_called_with([])
|
||||
|
||||
def test_setup_component(self):
|
||||
"""Test setup component with devices."""
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestEfergySensor(unittest.TestCase):
|
||||
DEVICES = []
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def add_devices(self, devices, mock):
|
||||
def add_entities(self, devices, mock):
|
||||
"""Mock add devices."""
|
||||
mock_responses(mock)
|
||||
for device in devices:
|
||||
|
||||
@@ -59,8 +59,8 @@ class PyFidoFakeModule():
|
||||
FidoClient = FidoClientMockError
|
||||
|
||||
|
||||
def fake_async_add_devices(component, update_before_add=False):
|
||||
"""Fake async_add_devices function."""
|
||||
def fake_async_add_entities(component, update_before_add=False):
|
||||
"""Fake async_add_entities function."""
|
||||
pass
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_error(hass, caplog):
|
||||
sys.modules['pyfido.client'] = PyFidoClientFakeModule()
|
||||
|
||||
config = {}
|
||||
fake_async_add_devices = MagicMock()
|
||||
fake_async_add_entities = MagicMock()
|
||||
yield from fido.async_setup_platform(hass, config,
|
||||
fake_async_add_devices)
|
||||
assert fake_async_add_devices.called is False
|
||||
fake_async_add_entities)
|
||||
assert fake_async_add_entities.called is False
|
||||
@@ -44,18 +44,18 @@ async def test_default_setup(hass, aioclient_mock):
|
||||
|
||||
async def test_setup_timeout_error(hass, aioclient_mock):
|
||||
"""Expected failures caused by a timeout in API response."""
|
||||
fake_async_add_devices = MagicMock()
|
||||
fake_async_add_entities = MagicMock()
|
||||
|
||||
aioclient_mock.get(re.compile('api.foobot.io/v2/owner/.*'),
|
||||
exc=asyncio.TimeoutError())
|
||||
with pytest.raises(PlatformNotReady):
|
||||
await foobot.async_setup_platform(hass, {'sensor': VALID_CONFIG},
|
||||
fake_async_add_devices)
|
||||
fake_async_add_entities)
|
||||
|
||||
|
||||
async def test_setup_permanent_error(hass, aioclient_mock):
|
||||
"""Expected failures caused by permanent errors in API response."""
|
||||
fake_async_add_devices = MagicMock()
|
||||
fake_async_add_entities = MagicMock()
|
||||
|
||||
errors = [400, 401, 403]
|
||||
for error in errors:
|
||||
@@ -63,13 +63,13 @@ async def test_setup_permanent_error(hass, aioclient_mock):
|
||||
status=error)
|
||||
result = await foobot.async_setup_platform(hass,
|
||||
{'sensor': VALID_CONFIG},
|
||||
fake_async_add_devices)
|
||||
fake_async_add_entities)
|
||||
assert result is None
|
||||
|
||||
|
||||
async def test_setup_temporary_error(hass, aioclient_mock):
|
||||
"""Expected failures caused by temporary errors in API response."""
|
||||
fake_async_add_devices = MagicMock()
|
||||
fake_async_add_entities = MagicMock()
|
||||
|
||||
errors = [429, 500]
|
||||
for error in errors:
|
||||
@@ -78,4 +78,4 @@ async def test_setup_temporary_error(hass, aioclient_mock):
|
||||
with pytest.raises(PlatformNotReady):
|
||||
await foobot.async_setup_platform(hass,
|
||||
{'sensor': VALID_CONFIG},
|
||||
fake_async_add_devices)
|
||||
fake_async_add_entities)
|
||||
@@ -99,7 +99,7 @@ def test_error(hass, caplog):
|
||||
sys.modules['pyhydroquebec.client'] = PyHydroQuebecClientFakeModule()
|
||||
|
||||
config = {}
|
||||
fake_async_add_devices = MagicMock()
|
||||
fake_async_add_entities = MagicMock()
|
||||
yield from hydroquebec.async_setup_platform(hass, config,
|
||||
fake_async_add_devices)
|
||||
assert fake_async_add_devices.called is False
|
||||
fake_async_add_entities)
|
||||
assert fake_async_add_entities.called is False
|
||||
@@ -22,7 +22,7 @@ class TestKiraSensor(unittest.TestCase):
|
||||
# pylint: disable=invalid-name
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -41,7 +41,7 @@ class TestKiraSensor(unittest.TestCase):
|
||||
# pylint: disable=protected-access
|
||||
def test_kira_sensor_callback(self):
|
||||
"""Ensure Kira sensor properly updates its attributes from callback."""
|
||||
kira.setup_platform(self.hass, TEST_CONFIG, self.add_devices,
|
||||
kira.setup_platform(self.hass, TEST_CONFIG, self.add_entities,
|
||||
DISCOVERY_INFO)
|
||||
assert len(self.DEVICES) == 1
|
||||
sensor = self.DEVICES[0]
|
||||
|
||||
@@ -42,10 +42,10 @@ class TestMelissa(unittest.TestCase):
|
||||
self.hass.data[DATA_MELISSA] = self.api
|
||||
|
||||
config = {}
|
||||
add_devices = Mock()
|
||||
add_entities = Mock()
|
||||
discovery_info = {}
|
||||
|
||||
melissa.setup_platform(self.hass, config, add_devices, discovery_info)
|
||||
melissa.setup_platform(self.hass, config, add_entities, discovery_info)
|
||||
|
||||
def test_name(self):
|
||||
"""Test name property."""
|
||||
|
||||
@@ -193,7 +193,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
# pylint: disable=invalid-name
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, update):
|
||||
def add_entities(self, devices, update):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -221,7 +221,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'diskspace'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual('263.10', device.state)
|
||||
@@ -248,7 +248,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'diskspace'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual('263.10', device.state)
|
||||
@@ -275,7 +275,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'commands'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -302,7 +302,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'movies'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -329,7 +329,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'upcoming'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -360,7 +360,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'upcoming'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -387,7 +387,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'status'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual('0.2.0.210', device.state)
|
||||
@@ -413,7 +413,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
],
|
||||
"ssl": "true"
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -441,7 +441,7 @@ class TestRadarrSetup(unittest.TestCase):
|
||||
'upcoming'
|
||||
]
|
||||
}
|
||||
radarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
radarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(None, device.state)
|
||||
@@ -16,7 +16,7 @@ class TestRingSensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, action):
|
||||
def add_entities(self, devices, action):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -66,7 +66,7 @@ class TestRingSensorSetup(unittest.TestCase):
|
||||
base_ring.setup(self.hass, VALID_CONFIG)
|
||||
ring.setup_platform(self.hass,
|
||||
self.config,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
for device in self.DEVICES:
|
||||
|
||||
@@ -60,7 +60,7 @@ class TestSeason(unittest.TestCase):
|
||||
CONFIG_ASTRONOMICAL = {'type': 'astronomical'}
|
||||
CONFIG_METEOROLOGICAL = {'type': 'meteorological'}
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICE = device
|
||||
|
||||
@@ -16,7 +16,7 @@ class TestSleepIQSensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -49,7 +49,7 @@ class TestSleepIQSensorSetup(unittest.TestCase):
|
||||
|
||||
sleepiq.setup_platform(self.hass,
|
||||
self.config,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
MagicMock())
|
||||
self.assertEqual(2, len(self.DEVICES))
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
# pylint: disable=invalid-name
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, update):
|
||||
def add_entities(self, devices, update):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -607,7 +607,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'diskspace'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual('263.10', device.state)
|
||||
@@ -634,7 +634,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'diskspace'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual('263.10', device.state)
|
||||
@@ -661,7 +661,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'commands'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -688,7 +688,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'queue'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -715,7 +715,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'series'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -742,7 +742,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'wanted'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -769,7 +769,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'upcoming'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -800,7 +800,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'upcoming'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -827,7 +827,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'status'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual('2.0.0.1121', device.state)
|
||||
@@ -854,7 +854,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
],
|
||||
"ssl": "true"
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(1, device.state)
|
||||
@@ -882,7 +882,7 @@ class TestSonarrSetup(unittest.TestCase):
|
||||
'upcoming'
|
||||
]
|
||||
}
|
||||
sonarr.setup_platform(self.hass, config, self.add_devices, None)
|
||||
sonarr.setup_platform(self.hass, config, self.add_entities, None)
|
||||
for device in self.DEVICES:
|
||||
device.update()
|
||||
self.assertEqual(None, device.state)
|
||||
@@ -48,14 +48,14 @@ class TestTCPSensor(unittest.TestCase):
|
||||
|
||||
@patch('homeassistant.components.sensor.tcp.TcpSensor.update')
|
||||
def test_setup_platform_valid_config(self, mock_update):
|
||||
"""Check a valid configuration and call add_devices with sensor."""
|
||||
"""Check a valid configuration and call add_entities with sensor."""
|
||||
with assert_setup_component(0, 'sensor'):
|
||||
assert setup_component(self.hass, 'sensor', TEST_CONFIG)
|
||||
|
||||
add_devices = Mock()
|
||||
tcp.setup_platform(None, TEST_CONFIG['sensor'], add_devices)
|
||||
assert add_devices.called
|
||||
assert isinstance(add_devices.call_args[0][0][0], tcp.TcpSensor)
|
||||
add_entities = Mock()
|
||||
tcp.setup_platform(None, TEST_CONFIG['sensor'], add_entities)
|
||||
assert add_entities.called
|
||||
assert isinstance(add_entities.call_args[0][0][0], tcp.TcpSensor)
|
||||
|
||||
def test_setup_platform_invalid_config(self):
|
||||
"""Check an invalid configuration."""
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestTimeDateSensor(unittest.TestCase):
|
||||
# pylint: disable=invalid-name
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
|
||||
@@ -23,7 +23,7 @@ class TestVultrSensorSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, action):
|
||||
def add_entities(self, devices, action):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -71,7 +71,7 @@ class TestVultrSensorSetup(unittest.TestCase):
|
||||
|
||||
for config in self.configs:
|
||||
setup = vultr.setup_platform(
|
||||
self.hass, config, self.add_devices, None)
|
||||
self.hass, config, self.add_entities, None)
|
||||
|
||||
self.assertIsNone(setup)
|
||||
|
||||
@@ -160,7 +160,7 @@ class TestVultrSensorSetup(unittest.TestCase):
|
||||
} # No subs at all
|
||||
|
||||
no_sub_setup = vultr.setup_platform(
|
||||
self.hass, bad_conf, self.add_devices, None)
|
||||
self.hass, bad_conf, self.add_entities, None)
|
||||
|
||||
self.assertIsNone(no_sub_setup)
|
||||
self.assertEqual(0, len(self.DEVICES))
|
||||
@@ -26,7 +26,7 @@ class TestVultrSwitchSetup(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices, action):
|
||||
def add_entities(self, devices, action):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
self.DEVICES.append(device)
|
||||
@@ -71,7 +71,7 @@ class TestVultrSwitchSetup(unittest.TestCase):
|
||||
for config in self.configs:
|
||||
vultr.setup_platform(self.hass,
|
||||
config,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
self.assertEqual(len(self.DEVICES), 3)
|
||||
@@ -181,7 +181,7 @@ class TestVultrSwitchSetup(unittest.TestCase):
|
||||
|
||||
no_subs_setup = vultr.setup_platform(self.hass,
|
||||
bad_conf,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
self.assertIsNotNone(no_subs_setup)
|
||||
@@ -193,7 +193,7 @@ class TestVultrSwitchSetup(unittest.TestCase):
|
||||
|
||||
wrong_subs_setup = vultr.setup_platform(self.hass,
|
||||
bad_conf,
|
||||
self.add_devices,
|
||||
self.add_entities,
|
||||
None)
|
||||
|
||||
self.assertIsNotNone(wrong_subs_setup)
|
||||
@@ -290,11 +290,11 @@ async def test_http_api_wrong_data(hass, aiohttp_client):
|
||||
def test_create_matcher():
|
||||
"""Test the create matcher method."""
|
||||
# Basic sentence
|
||||
pattern = conversation._create_matcher('Hello world')
|
||||
pattern = conversation.create_matcher('Hello world')
|
||||
assert pattern.match('Hello world') is not None
|
||||
|
||||
# Match a part
|
||||
pattern = conversation._create_matcher('Hello {name}')
|
||||
pattern = conversation.create_matcher('Hello {name}')
|
||||
match = pattern.match('hello world')
|
||||
assert match is not None
|
||||
assert match.groupdict()['name'] == 'world'
|
||||
@@ -302,7 +302,7 @@ def test_create_matcher():
|
||||
assert no_match is None
|
||||
|
||||
# Optional and matching part
|
||||
pattern = conversation._create_matcher('Turn on [the] {name}')
|
||||
pattern = conversation.create_matcher('Turn on [the] {name}')
|
||||
match = pattern.match('turn on the kitchen lights')
|
||||
assert match is not None
|
||||
assert match.groupdict()['name'] == 'kitchen lights'
|
||||
@@ -313,7 +313,7 @@ def test_create_matcher():
|
||||
assert match is None
|
||||
|
||||
# Two different optional parts, 1 matching part
|
||||
pattern = conversation._create_matcher('Turn on [the] [a] {name}')
|
||||
pattern = conversation.create_matcher('Turn on [the] [a] {name}')
|
||||
match = pattern.match('turn on the kitchen lights')
|
||||
assert match is not None
|
||||
assert match.groupdict()['name'] == 'kitchen lights'
|
||||
@@ -325,13 +325,13 @@ def test_create_matcher():
|
||||
assert match.groupdict()['name'] == 'kitchen light'
|
||||
|
||||
# Strip plural
|
||||
pattern = conversation._create_matcher('Turn {name}[s] on')
|
||||
pattern = conversation.create_matcher('Turn {name}[s] on')
|
||||
match = pattern.match('turn kitchen lights on')
|
||||
assert match is not None
|
||||
assert match.groupdict()['name'] == 'kitchen light'
|
||||
|
||||
# Optional 2 words
|
||||
pattern = conversation._create_matcher('Turn [the great] {name} on')
|
||||
pattern = conversation.create_matcher('Turn [the great] {name} on')
|
||||
match = pattern.match('turn the great kitchen lights on')
|
||||
assert match is not None
|
||||
assert match.groupdict()['name'] == 'kitchen lights'
|
||||
|
||||
@@ -77,9 +77,9 @@ class DysonTest(unittest.TestCase):
|
||||
def test_setup_component_with_no_devices(self):
|
||||
"""Test setup component with no devices."""
|
||||
self.hass.data[dyson.DYSON_DEVICES] = []
|
||||
add_devices = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, {}, add_devices)
|
||||
add_devices.assert_called_with([])
|
||||
add_entities = mock.MagicMock()
|
||||
dyson.setup_platform(self.hass, {}, add_entities)
|
||||
add_entities.assert_called_with([])
|
||||
|
||||
def test_setup_component(self):
|
||||
"""Test setup component with devices."""
|
||||
|
||||
@@ -76,7 +76,7 @@ class TestWeather(unittest.TestCase):
|
||||
|
||||
DEVICES = []
|
||||
|
||||
def add_devices(self, devices):
|
||||
def add_entities(self, devices):
|
||||
"""Mock add devices."""
|
||||
for device in devices:
|
||||
device.update()
|
||||
|
||||
@@ -128,24 +128,24 @@ def test_setup_platform(hass, mock_openzwave):
|
||||
mock_device = MagicMock()
|
||||
hass.data[DATA_NETWORK] = MagicMock()
|
||||
hass.data[zwave.DATA_DEVICES] = {456: mock_device}
|
||||
async_add_devices = MagicMock()
|
||||
async_add_entities = MagicMock()
|
||||
|
||||
result = yield from zwave.async_setup_platform(
|
||||
hass, None, async_add_devices, None)
|
||||
hass, None, async_add_entities, None)
|
||||
assert not result
|
||||
assert not async_add_devices.called
|
||||
assert not async_add_entities.called
|
||||
|
||||
result = yield from zwave.async_setup_platform(
|
||||
hass, None, async_add_devices, {const.DISCOVERY_DEVICE: 123})
|
||||
hass, None, async_add_entities, {const.DISCOVERY_DEVICE: 123})
|
||||
assert not result
|
||||
assert not async_add_devices.called
|
||||
assert not async_add_entities.called
|
||||
|
||||
result = yield from zwave.async_setup_platform(
|
||||
hass, None, async_add_devices, {const.DISCOVERY_DEVICE: 456})
|
||||
hass, None, async_add_entities, {const.DISCOVERY_DEVICE: 456})
|
||||
assert result
|
||||
assert async_add_devices.called
|
||||
assert len(async_add_devices.mock_calls) == 1
|
||||
assert async_add_devices.mock_calls[0][1][0] == [mock_device]
|
||||
assert async_add_entities.called
|
||||
assert len(async_add_entities.mock_calls) == 1
|
||||
assert async_add_entities.mock_calls[0][1][0] == [mock_device]
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
||||
Reference in new issue
Block a user