-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Add additional tests for Matter update entity #122575
Add additional tests for Matter update entity #122575
Conversation
Extend test coverage for Matter update entity. This includes tests for error handling and state store/restore.
Hey there @home-assistant/matter, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
This comment was marked as off-topic.
This comment was marked as off-topic.
) | ||
|
||
|
||
async def test_update_state_restore( |
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.
We have mock_restore_cache_with_extra_data
to help test loading of restored state.
Example:
core/tests/components/zwave_js/test_update.py
Lines 706 to 739 in 7348a1f
async def test_update_entity_partial_restore_data_2( | |
hass: HomeAssistant, | |
client, | |
climate_radio_thermostat_ct100_plus_different_endpoints, | |
hass_ws_client: WebSocketGenerator, | |
) -> None: | |
"""Test second scenario where update entity has partial restore data.""" | |
mock_restore_cache_with_extra_data( | |
hass, | |
[ | |
( | |
State( | |
UPDATE_ENTITY, | |
STATE_ON, | |
{ | |
ATTR_INSTALLED_VERSION: "10.7", | |
ATTR_LATEST_VERSION: "10.8", | |
ATTR_SKIPPED_VERSION: None, | |
}, | |
), | |
{"latest_version_firmware": None}, | |
) | |
], | |
) | |
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"}) | |
entry.add_to_hass(hass) | |
await hass.config_entries.async_setup(entry.entry_id) | |
await hass.async_block_till_done() | |
state = hass.states.get(UPDATE_ENTITY) | |
assert state | |
assert state.state == STATE_UNKNOWN | |
assert state.attributes[ATTR_SKIPPED_VERSION] is None | |
assert state.attributes[ATTR_LATEST_VERSION] is None |
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.
I took inspiration from test_restore_sensor_save_state
for this test.
From what I can tell mock_restore_cache_with_extra_data
would only allow to test the restore side, but not really the saving side (making sure the update information makes it into the extra data).
The way I wrote the test is really what I (the user) is interested in: Make sure the update information survives a restart.
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.
I didn't mean that we should remove this test. But we need to add another test that uses that helper and tests the loading.
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.
I see, yeah seems sensible to test the loading side only, to make sure this remains compatible/correct.
We don't use much of the extra data currently, essentially we just use it to get the software update integer version to pass it to the update call. I guess it could be debated if the implementation of the Matter update entity should make use more of the extra data directly 🤔 But that would need an update entity change too.
Anyways, the current test really tests what extra data is used now, so IMHO this is already a good step forward in test coverage.
@jvmahon please open an issue instead. |
Looks like two errors and the polling mechanism are still uncovered. |
@jvmahon like Martin already noted: don't start commenting on random/unrelated PR's and/or issue reports, create your own issue report if you find something. I know you are trying to be helpful in these cases but please respect our developer workflow. To quickly answer your message about that P2 sensor. We are in fact checking (server side) for "software version valid" but Aqara did not set that. They just did on our request so probably your device is now bricked because you updated it right before that. NOTE: Maybe its not bricked and you just need to to reset and recommission it. |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
We check device updates every 12h currently. Use the freezer to skip time. Still add a test which uses the service call to make sure this works too.
Breaking change
Proposed change
Extend test coverage for Matter update entity. This includes tests for error handling and state store/restore.
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: