-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Update pyunifi component to use APIError passed from pyunifi 2.13. Better accommodate login failures with wrapper in pyunifi 2.13. #7899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ebd74a0
Pyunifi update
finish06 c00677f
Update pyunifi_test
finish06 f14b977
Import API Error
finish06 2c5b263
Adjust test_unifi.py to import APIError
finish06 f17ce9d
Remove urllib import
finish06 a4bc193
Remove urllib import from test
finish06 8016353
Try fix mock
balloob 2cb7056
Remove automations.yaml
balloob 44b432e
Lint
balloob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,7 @@ | |
| 'pywebpush', | ||
| 'PyJWT', | ||
| 'restrictedpython', | ||
| 'pyunifi', | ||
| ) | ||
|
|
||
| IGNORE_PACKAGES = ( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| """The tests for the Unifi WAP device tracker platform.""" | ||
| from unittest import mock | ||
| import urllib | ||
| from pyunifi.controller import APIError | ||
|
|
||
| import pytest | ||
| import voluptuous as vol | ||
|
|
@@ -13,11 +13,8 @@ | |
| @pytest.fixture | ||
| def mock_ctrl(): | ||
| """Mock pyunifi.""" | ||
| module = mock.MagicMock() | ||
| with mock.patch.dict('sys.modules', { | ||
| 'pyunifi.controller': module.controller, | ||
| }): | ||
| yield module.controller.Controller | ||
| with mock.patch('pyunifi.controller.Controller') as mock_control: | ||
| yield mock_control | ||
|
|
||
|
|
||
| @pytest.fixture | ||
|
|
@@ -100,7 +97,7 @@ def test_config_controller_failed(hass, mock_ctrl, mock_scanner): | |
| CONF_PASSWORD: 'password', | ||
| } | ||
| } | ||
| mock_ctrl.side_effect = urllib.error.HTTPError( | ||
| mock_ctrl.side_effect = APIError( | ||
| '/', 500, 'foo', {}, None) | ||
| result = unifi.get_scanner(hass, config) | ||
| assert result is False | ||
|
|
@@ -122,7 +119,7 @@ def test_scanner_update(): | |
| def test_scanner_update_error(): | ||
| """Test the scanner update for error.""" | ||
| ctrl = mock.MagicMock() | ||
| ctrl.get_clients.side_effect = urllib.error.HTTPError( | ||
| ctrl.get_clients.side_effect = APIError( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undefined name 'APIError' |
||
| '/', 500, 'foo', {}, None) | ||
| unifi.UnifiScanner(ctrl) | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined name 'APIError'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to import APIError first.