1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add new_device_discovered event (#4132)

This commit is contained in:
Lewis Juggins
2016-11-02 04:52:27 +00:00
committed by Paulus Schoutsen
parent e487a09190
commit a5fb284717
2 changed files with 23 additions and 0 deletions

View File

@@ -306,6 +306,24 @@ class TestComponentsDeviceTracker(unittest.TestCase):
self.assertEqual(mock_see.call_count, 1)
self.assertEqual(mock_see.call_args, call(**params))
def test_new_device_event_fired(self):
"""Test that the device tracker will fire an event."""
self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
test_events = []
def listener(event):
"""Helper method that will verify our event got called."""
test_events.append(event)
self.hass.bus.listen("device_tracker_new_device", listener)
device_tracker.see(self.hass, 'mac_1', host_name='hello')
device_tracker.see(self.hass, 'mac_1', host_name='hello')
self.hass.block_till_done()
self.assertEqual(1, len(test_events))
# pylint: disable=invalid-name
def test_not_write_duplicate_yaml_keys(self):
"""Test that the device tracker will not generate invalid YAML."""