mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 12:30:31 +00:00
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
"""Test Onkyo component setup process."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components.onkyo import async_setup_entry
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.exceptions import ConfigEntryNotReady
|
|
|
|
from . import create_empty_config_entry, create_receiver_info, setup_integration
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_load_unload_entry(
|
|
hass: HomeAssistant,
|
|
config_entry: MockConfigEntry,
|
|
) -> None:
|
|
"""Test load and unload entry."""
|
|
|
|
config_entry = create_empty_config_entry()
|
|
receiver_info = create_receiver_info(1)
|
|
await setup_integration(hass, config_entry, receiver_info)
|
|
|
|
assert config_entry.state is ConfigEntryState.LOADED
|
|
|
|
await hass.config_entries.async_unload(config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
|
|
|
|
|
async def test_no_connection(
|
|
hass: HomeAssistant,
|
|
config_entry: MockConfigEntry,
|
|
) -> None:
|
|
"""Test update options."""
|
|
|
|
config_entry = create_empty_config_entry()
|
|
config_entry.add_to_hass(hass)
|
|
|
|
with (
|
|
patch(
|
|
"homeassistant.components.onkyo.async_interview",
|
|
return_value=None,
|
|
),
|
|
pytest.raises(ConfigEntryNotReady),
|
|
):
|
|
await async_setup_entry(hass, config_entry)
|