* Add MAC vendor lookup for device_tracker.

* Test vendor mac lookup and fix device attribute.

* Generate requirements.

* Style.

* Use hyphen instead of underscore to satisfy 'idna'.

https://github.com/kjd/idna/issues/17

* Resort imports.

* Refactor macvendor to use macvendors.com API instead of netaddr library.

* Test vendor lookup using macvendors.com api.

* Remove debugging.

* Correct description.

* No longer needed.

* Device tracker is now an async component. Fix ddwrt tests.

* Fix linting.

* Add test case for error conditions.

* There is no reason to retry failes vendor loopups as they won't be saved to the file anyways at that point.

* Sorry, bad assumption, this only made things worse.

* Wait for async parts during setup component to complete before asserting results.

* Fix linting.

* Is generated when running 'coverage html'.

* Undo isort.

* Make aioclient_mock exception more generic.

* Only lookup mac vendor string with adding new device to known_devices.yaml.

* Undo isort.

* Revert unneeded change.

* Adjust to use new websession pattern.

* Always make sure to cleanup response.

* Use correct function to release response.

* Fix tests.
This commit is contained in:
Johan Bloemberg authored and Paulus Schoutsen committed 2016-12-01 18:30:41 -08:00
1 parent f09b888a8a
commit 08f8e540e3
5 files changed
+156 -4

No files matched your search

@@ -3,6 +3,7 @@ import os
import unittest
from unittest import mock
import logging
import re
import requests
import requests_mock
@@ -17,6 +18,8 @@ from homeassistant.util import slugify
from tests.common import (
get_test_home_assistant, assert_setup_component, load_fixture)
from ...test_util.aiohttp import mock_aiohttp_client
TEST_HOST = '127.0.0.1'
_LOGGER = logging.getLogger(__name__)
@@ -26,6 +29,13 @@ class TestDdwrt(unittest.TestCase):
hass = None
def run(self, result=None):
"""Mock out http calls to macvendor API for whole test suite."""
with mock_aiohttp_client() as aioclient_mock:
macvendor_re = re.compile('http://api.macvendors.com/.*')
aioclient_mock.get(macvendor_re, text='')
super().run(result)
def setup_method(self, _):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
@@ -136,6 +146,7 @@ class TestDdwrt(unittest.TestCase):
CONF_USERNAME: 'fake_user',
CONF_PASSWORD: '0'
}})
self.hass.block_till_done()
path = self.hass.config.path(device_tracker.YAML_DEVICES)
devices = config.load_yaml_config_file(path)
@@ -164,6 +175,7 @@ class TestDdwrt(unittest.TestCase):
CONF_USERNAME: 'fake_user',
CONF_PASSWORD: '0'
}})
self.hass.block_till_done()
path = self.hass.config.path(device_tracker.YAML_DEVICES)
devices = config.load_yaml_config_file(path)
@@ -192,6 +204,7 @@ class TestDdwrt(unittest.TestCase):
CONF_USERNAME: 'fake_user',
CONF_PASSWORD: '0'
}})
self.hass.block_till_done()
path = self.hass.config.path(device_tracker.YAML_DEVICES)
devices = config.load_yaml_config_file(path)