add_devices -> add_entities (#16171)
* add_devices -> add_entities * Lint * PyLint * Revert external method in scsgate
This commit is contained in:
1 parent
37fd438717
commit
994b829cb4
839 files changed
+2121
-2008
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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -80,7 +80,7 @@ async def async_setup_cast_internal_discovery(hass, config=None,
|
||||
listener.services[service_name] = attr.astuple(info)
|
||||
discovery_callback(service_name)
|
||||
|
||||
return discover_chromecast, add_devices
|
||||
return discover_chromecast, add_entities
|
||||
|
||||
|
||||
async def async_setup_media_player_cast(hass: HomeAssistantType,
|
||||
@@ -214,30 +214,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)
|
||||
@@ -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