Actually test calling async macvendor lookup and fix it. (#4718)
This commit is contained in:
parent
c8c6bee539
commit
9bf13231f7
2 changed files with 19 additions and 1 deletions
|
@ -282,7 +282,7 @@ class DeviceTracker(object):
|
||||||
list(self.group.tracking) + [device.entity_id])
|
list(self.group.tracking) + [device.entity_id])
|
||||||
|
|
||||||
# lookup mac vendor string to be stored in config
|
# lookup mac vendor string to be stored in config
|
||||||
device.set_vendor_for_mac()
|
yield from device.set_vendor_for_mac()
|
||||||
|
|
||||||
# update known_devices.yaml
|
# update known_devices.yaml
|
||||||
self.hass.async_add_job(
|
self.hass.async_add_job(
|
||||||
|
|
|
@ -256,6 +256,24 @@ class TestComponentsDeviceTracker(unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(device.vendor, 'unknown')
|
self.assertEqual(device.vendor, 'unknown')
|
||||||
|
|
||||||
|
def test_mac_vendor_lookup_on_see(self):
|
||||||
|
"""Test if macvendor is looked up when device is seen."""
|
||||||
|
mac = 'B8:27:EB:00:00:00'
|
||||||
|
vendor_string = 'Raspberry Pi Foundation'
|
||||||
|
|
||||||
|
tracker = device_tracker.DeviceTracker(
|
||||||
|
self.hass, timedelta(seconds=60), 0, [])
|
||||||
|
|
||||||
|
with mock_aiohttp_client() as aioclient_mock:
|
||||||
|
aioclient_mock.get('http://api.macvendors.com/b8:27:eb',
|
||||||
|
text=vendor_string)
|
||||||
|
|
||||||
|
run_coroutine_threadsafe(
|
||||||
|
tracker.async_see(mac=mac), self.hass.loop).result()
|
||||||
|
assert aioclient_mock.call_count == 1, \
|
||||||
|
'No http request for macvendor made!'
|
||||||
|
self.assertEqual(tracker.devices['b827eb000000'].vendor, vendor_string)
|
||||||
|
|
||||||
def test_discovery(self):
|
def test_discovery(self):
|
||||||
"""Test discovery."""
|
"""Test discovery."""
|
||||||
scanner = get_component('device_tracker.test').SCANNER
|
scanner = get_component('device_tracker.test').SCANNER
|
||||||
|
|
Loading…
Add table
Reference in a new issue