Ignore cloudhook already removed in mobile app#111122
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
So I added the test, but there is a try catch in the config_entries, which prohibits me from actually testing the raise: core/homeassistant/config_entries.py Lines 705 to 712 in 490c03d This means that the following test: @pytest.mark.parametrize("exception", (None, CloudNotAvailable, ValueError))
async def test_remove_cloudhook(
hass: HomeAssistant,
hass_admin_user: MockUser,
exception: Exception | None,
) -> None:
"""Test removing a cloud hook when config entry is removed."""
async def additional_steps(
config_entry: ConfigEntry, mock_create_cloudhook: Mock, cloud_hook: str
) -> None:
webhook_id = config_entry.data[CONF_WEBHOOK_ID]
assert config_entry.data[CONF_CLOUDHOOK_URL] == cloud_hook
with patch(
"homeassistant.components.cloud.async_delete_cloudhook",
side_effect=exception,
) as delete_cloudhook:
await hass.config_entries.async_remove(config_entry.entry_id)
await hass.async_block_till_done()
delete_cloudhook.assert_called_once_with(hass, webhook_id)
await _test_create_cloud_hook(hass, hass_admin_user, {}, True, additional_steps)Works both on this branch and on Are there better ways to check if the exception is surpressed, other than using a caplog? |
|
No, caplog seems to be the only thing we can use, since nothing happens after the call that will raise. |

Proposed change
Ignore cloudhook already removed in mobile app
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..coveragerc.To help with the load of incoming pull requests: