Improve onewire test coverage (#90184)

This commit is contained in:
epenet 2023-03-26 23:46:52 +02:00 committed by GitHub
parent 2642d37505
commit c06ec1f78f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
"""Tests for 1-Wire config flow."""
from copy import deepcopy
from unittest.mock import MagicMock, patch
import aiohttp
@ -74,6 +75,27 @@ async def test_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> N
assert not hass.data.get(DOMAIN)
async def test_update_options(
hass: HomeAssistant, config_entry: ConfigEntry, owproxy: MagicMock
) -> None:
"""Test update options triggers reload."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert config_entry.state is ConfigEntryState.LOADED
assert owproxy.call_count == 1
new_options = deepcopy(dict(config_entry.options))
new_options["device_options"].clear()
hass.config_entries.async_update_entry(config_entry, options=new_options)
await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert config_entry.state is ConfigEntryState.LOADED
assert owproxy.call_count == 2
@patch("homeassistant.components.onewire.PLATFORMS", [Platform.SENSOR])
async def test_registry_cleanup(
hass: HomeAssistant,