Add option to set default hide if away for new devices (#10762)

* Option to change hide_if_away

* tests fix

* change new device defaults

* tests and requested changes

* fix assert
This commit is contained in:
Mitko Masarliev authored and Paulus Schoutsen committed 2017-12-05 21:56:43 -08:00
1 parent 3af527b1b5
commit 8e4942088e
4 files changed
+53 -15

No files matched your search

+17 -5
View File
@@ -123,7 +123,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
'My device', None, None, False),
device_tracker.Device(self.hass, True, True, 'your_device',
'AB:01', 'Your device', None, None, False)]
device_tracker.DeviceTracker(self.hass, False, True, devices)
device_tracker.DeviceTracker(self.hass, False, True, {}, devices)
_LOGGER.debug(mock_warning.call_args_list)
assert mock_warning.call_count == 1, \
"The only warning call should be duplicates (check DEBUG)"
@@ -137,7 +137,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
'AB:01', 'My device', None, None, False),
device_tracker.Device(self.hass, True, True, 'my_device',
None, 'Your device', None, None, False)]
device_tracker.DeviceTracker(self.hass, False, True, devices)
device_tracker.DeviceTracker(self.hass, False, True, {}, devices)
_LOGGER.debug(mock_warning.call_args_list)
assert mock_warning.call_count == 1, \
@@ -299,7 +299,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
vendor_string = 'Raspberry Pi Foundation'
tracker = device_tracker.DeviceTracker(
self.hass, timedelta(seconds=60), 0, [])
self.hass, timedelta(seconds=60), 0, {}, [])
with mock_aiohttp_client() as aioclient_mock:
aioclient_mock.get('http://api.macvendors.com/b8:27:eb',
@@ -622,7 +622,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
def test_see_failures(self, mock_warning):
"""Test that the device tracker see failures."""
tracker = device_tracker.DeviceTracker(
self.hass, timedelta(seconds=60), 0, [])
self.hass, timedelta(seconds=60), 0, {}, [])
# MAC is not a string (but added)
tracker.see(mac=567, host_name="Number MAC")
@@ -654,7 +654,7 @@ class TestComponentsDeviceTracker(unittest.TestCase):
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, [])
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,
@@ -663,6 +663,18 @@ class TestComponentsDeviceTracker(unittest.TestCase):
assert config[0].icon == 'mdi:icon'
assert config[0].entity_picture == 'pic_url'
def test_default_hide_if_away_is_used(self):
"""Test that default track_new is used."""
tracker = device_tracker.DeviceTracker(
self.hass, timedelta(seconds=60), False,
{device_tracker.CONF_AWAY_HIDE: True}, [])
tracker.see(dev_id=12)
self.hass.block_till_done()
config = device_tracker.load_config(self.yaml_devices, self.hass,
timedelta(seconds=0))
assert len(config) == 1
self.assertTrue(config[0].hidden)
@asyncio.coroutine
def test_async_added_to_hass(hass):