Update pyunifi component to use APIError passed from pyunifi 2.13. Better accommodate login failures with wrapper in pyunifi 2.13.#7899
Conversation
There was a problem hiding this comment.
You'll need to import APIError first.
|
In need of assistance regarding updating the test_unifi.py file. Thanks! |
|
Add |
|
@finish06 please make sure that class APIError(Exception):
"""Base class for unifi errors."""
pass |
|
@balloob I definitely have it setup in the manner you recommend. The error still occurs even though 'APIError' is a child of 'Exception'. |
|
Ooooooooooooooooooooh I get it. The old unifi tests were mocking out the unify lib: https://github.com/home-assistant/home-assistant/blob/dev/tests/components/device_tracker/test_unifi.py#L13-L20 |
|
@balloob alright, I am glad you had a eureka, however, my naivety prevents me from understanding what the implications of the new insight... I know that adding |
|
That fixture patches the imported modules to always load a fake one. You can remove it and instead make sure that the controller is still mocked and returned from the fixture. |
|
I tried something, not sure if it will work. |
…tter accommodate login failures with wrapper in pyunifi 2.13. (#7899) * Pyunifi update * Update pyunifi_test * Import API Error * Adjust test_unifi.py to import APIError * Remove urllib import * Remove urllib import from test * Try fix mock * Remove automations.yaml * Lint
|
Cherry-picked for 0.47 👍 |
Description:
Added wrapper to pyunifi 2.13 '_read' function to improve handling of authentication related failures. Updated unifi component to accept 'APIError' as passed from pyunifi. Adjusted
urllib3.exceptions.InsecureRequestWarningto display a single time.Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.If the code does not interact with devices:
toxrun successfully. Your PR cannot be merged unless tests pass