mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
Allow device_tracker platforms to specify picture and icon upon discovery (#8018)
* Allow device tracker platforms to specify picture * Allow device tracker to specify icon during discovery * Clean up and add tests * Fix lint * Fix test
This commit is contained in:
@@ -654,14 +654,25 @@ class TestComponentsDeviceTracker(unittest.TestCase):
|
||||
|
||||
assert len(config) == 4
|
||||
|
||||
@patch('homeassistant.components.device_tracker.async_log_exception')
|
||||
def test_config_failure(self, mock_ex):
|
||||
def test_config_failure(self):
|
||||
"""Test that the device tracker see failures."""
|
||||
with assert_setup_component(0, device_tracker.DOMAIN):
|
||||
setup_component(self.hass, device_tracker.DOMAIN,
|
||||
{device_tracker.DOMAIN: {
|
||||
device_tracker.CONF_CONSIDER_HOME: -1}})
|
||||
|
||||
def test_picture_and_icon_on_see_discovery(self):
|
||||
"""Test that picture and icon are set in initial see."""
|
||||
tracker = device_tracker.DeviceTracker(
|
||||
self.hass, timedelta(seconds=60), False, [])
|
||||
tracker.see(dev_id=11, picture='pic_url', icon='mdi:icon')
|
||||
self.hass.block_till_done()
|
||||
config = device_tracker.load_config(self.yaml_devices, self.hass,
|
||||
timedelta(seconds=0))
|
||||
assert len(config) == 1
|
||||
assert config[0].icon == 'mdi:icon'
|
||||
assert config[0].entity_picture == 'pic_url'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_async_added_to_hass(hass):
|
||||
@@ -691,3 +702,15 @@ def test_async_added_to_hass(hass):
|
||||
for key, val in attr.items():
|
||||
atr = state.attributes.get(key)
|
||||
assert atr == val, "{}={} expected: {}".format(key, atr, val)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_bad_platform(hass):
|
||||
"""Test bad platform."""
|
||||
config = {
|
||||
'device_tracker': [{
|
||||
'platform': 'bad_platform'
|
||||
}]
|
||||
}
|
||||
with assert_setup_component(0, device_tracker.DOMAIN):
|
||||
assert (yield from device_tracker.async_setup(hass, config))
|
||||
|
||||
Reference in New Issue
Block a user