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
Improve AsusWRT integration tests #102810
Conversation
Hey there @kennedyshead, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
tests/components/asuswrt/conftest.py
Outdated
@pytest.fixture(name="connect_legacy") | ||
def mock_controller_connect_legacy(mock_devices_legacy, mock_available_temps): | ||
"""Mock a successful connection with legacy library.""" | ||
with patch(ASUSWRT_LEGACY_LIB) as service_mock: |
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.
with patch(ASUSWRT_LEGACY_LIB) as service_mock: | |
with patch(ASUSWRT_LEGACY_LIB, spec_set=AsusWrtLegacy) as service_mock: |
Will create a mock with the same functions as AsusWrtLegacy
See https://docs.python.org/3/library/unittest.mock.html#patch
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.
Need to use spec
instead of spec_set
to be able to define connection attribute, otherwise it was always returning to me AttributeError: Mock object has no attribute 'connection'
. May be this is due to way that connection is defined in the library.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Any news here? There is something tat I miss to do? |
connect_legacy.return_value.connection.async_connect = AsyncMock( | ||
side_effect=side_effect | ||
) |
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.
connect_legacy.return_value.connection.async_connect = AsyncMock( | |
side_effect=side_effect | |
) | |
connect_legacy.return_value.connection.async_connect.side_effect=side_effect |
connect_legacy.return_value.connection.async_connect = AsyncMock( | ||
side_effect=side_effect | ||
) | ||
connect_legacy.return_value.async_get_nvram = AsyncMock() |
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.
Is this really required?
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.
No it isn't, I don''t remember why it was here😉.
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.
Thanks @ollo69 👍
Proposed change
Review AsusWRT integration tests adding
common.py
andconftest.py
for shared constants and patches. Addedtest_diagnostics
to complete codecov requirement.Type of change
Additional information
Checklist
black --fast 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
..coveragerc
.To help with the load of incoming pull requests: