Macvendor (#4468)
* 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:
1 parent
f09b888a8a
commit
08f8e540e3
5 files changed
+156
-4
No files matched your search
@@ -22,7 +22,8 @@ class AiohttpClientMocker:
|
||||
text=None,
|
||||
content=None,
|
||||
json=None,
|
||||
params=None):
|
||||
params=None,
|
||||
exc=None):
|
||||
"""Mock a request."""
|
||||
if json:
|
||||
text = _json.dumps(json)
|
||||
@@ -33,6 +34,8 @@ class AiohttpClientMocker:
|
||||
if params:
|
||||
url = str(yarl.URL(url).with_query(params))
|
||||
|
||||
self.exc = exc
|
||||
|
||||
self._mocks.append(AiohttpClientMockResponse(
|
||||
method, url, status, content))
|
||||
|
||||
@@ -68,6 +71,9 @@ class AiohttpClientMocker:
|
||||
for response in self._mocks:
|
||||
if response.match_request(method, url, params):
|
||||
self.mock_calls.append((method, url))
|
||||
|
||||
if self.exc:
|
||||
raise self.exc
|
||||
return response
|
||||
|
||||
assert False, "No mock registered for {} {}".format(method.upper(),
|
||||
|
||||
Reference in new issue
Block a user