-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Use non-autospec mock for Reolink's host tests #147619
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
Conversation
Hey there @starkillerOG, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
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.
Pull Request Overview
This PR switches Reolink host tests to use a non-autospec host mock (reolink_host
) instead of reolink_connect
and adds a missing renew
AsyncMock in the test fixture.
- Renamed fixture parameter and all references from
reolink_connect
toreolink_host
- Updated method calls on the host mock to match the new fixture
- Added
host_mock.renew = AsyncMock()
inconftest.py
to support renewal tests
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
tests/components/reolink/test_host.py | Replaced reolink_connect references with reolink_host and adjusted mocks in tests |
tests/components/reolink/conftest.py | Initialized renew as an AsyncMock on the host mock |
reolink_host.baichuan.events_active = False | ||
reolink_host.baichuan.subscribe_events.side_effect = ReolinkError("Test error") | ||
|
||
|
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.
[nitpick] These lines at the end of test_setup_with_tcp_push
set events_active
and a side effect on subscribe_events
, but the test does not trigger another subscription call afterward. Consider removing these redundant assignments to keep the test focused.
reolink_host.baichuan.events_active = False | |
reolink_host.baichuan.subscribe_events.side_effect = ReolinkError("Test error") |
Copilot uses AI. Check for mistakes.
reolink_host.baichuan.events_active = False | ||
reolink_host.baichuan.subscribe_events.side_effect = ReolinkError("Test error") | ||
|
||
|
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.
[nitpick] In test_unloading_with_tcp_push
, these lines set events_active
and a side effect on subscribe_events
after unloading, but no further behavior is asserted. You can remove these unused lines to reduce noise in the test.
reolink_host.baichuan.events_active = False | |
reolink_host.baichuan.subscribe_events.side_effect = ReolinkError("Test error") |
Copilot uses AI. Check for mistakes.
reolink_host.subscribed.return_value = True | ||
|
||
|
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.
[nitpick] This assignment in the test_ONVIF_not_supported
test is not used after the test assertion. It can be removed to clean up the test setup.
reolink_host.subscribed.return_value = True |
Copilot uses AI. Check for mistakes.
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.
LGTM, thank you very much!
Proposed change
Follow up to #146969
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: