mirror of
https://github.com/home-assistant/core.git
synced 2025-11-24 18:26:58 +00:00
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Test init of senz integration."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.config_entry_oauth2_flow import (
|
|
ImplementationUnavailableError,
|
|
)
|
|
|
|
from . import setup_integration
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_load_unload_entry(
|
|
hass: HomeAssistant,
|
|
mock_senz_client: MagicMock,
|
|
mock_config_entry: MockConfigEntry,
|
|
) -> None:
|
|
"""Test load and unload entry."""
|
|
await setup_integration(hass, mock_config_entry)
|
|
entry = mock_config_entry
|
|
|
|
assert entry.state is ConfigEntryState.LOADED
|
|
|
|
await hass.config_entries.async_unload(entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert entry.state is ConfigEntryState.NOT_LOADED
|
|
|
|
|
|
async def test_oauth_implementation_not_available(
|
|
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
|
) -> None:
|
|
"""Test that an unavailable OAuth implementation raises ConfigEntryNotReady."""
|
|
|
|
with patch(
|
|
"homeassistant.components.senz.async_get_config_entry_implementation",
|
|
side_effect=ImplementationUnavailableError,
|
|
):
|
|
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|