Test speedtest.net config entry lifecycle (#100280)
This commit is contained in:
parent
aedd06b9a9
commit
29d8be510e
1 changed files with 15 additions and 3 deletions
|
@ -5,7 +5,11 @@ from unittest.mock import MagicMock
|
|||
|
||||
import speedtest
|
||||
|
||||
from homeassistant.components.speedtestdotnet.const import DOMAIN
|
||||
from homeassistant.components.speedtestdotnet.const import (
|
||||
CONF_SERVER_ID,
|
||||
CONF_SERVER_NAME,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -27,16 +31,24 @@ async def test_setup_failed(hass: HomeAssistant, mock_api: MagicMock) -> None:
|
|||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||
"""Test removing SpeedTestDotNet."""
|
||||
async def test_entry_lifecycle(hass: HomeAssistant, mock_api: MagicMock) -> None:
|
||||
"""Test the SpeedTestDotNet entry lifecycle."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={},
|
||||
options={
|
||||
CONF_SERVER_NAME: "Country1 - Sponsor1 - Server1",
|
||||
CONF_SERVER_ID: "1",
|
||||
},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state == ConfigEntryState.LOADED
|
||||
assert hass.data[DOMAIN]
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue