mirror of
https://github.com/home-assistant/core.git
synced 2025-11-17 06:50:12 +00:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Norbert Rittel <norbert@rittel.de> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Test the Fing integration init."""
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components.fing.const import DOMAIN
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from . import init_integration
|
|
|
|
from tests.common import AsyncMock
|
|
from tests.conftest import MockConfigEntry
|
|
|
|
|
|
@pytest.mark.parametrize("api_type", ["new", "old"])
|
|
async def test_setup_entry_new_api(
|
|
hass: HomeAssistant,
|
|
mock_config_entry: MockConfigEntry,
|
|
mocked_fing_agent: AsyncMock,
|
|
api_type: str,
|
|
) -> None:
|
|
"""Test setup Fing Agent /w New API."""
|
|
entry = await init_integration(hass, mock_config_entry, mocked_fing_agent)
|
|
|
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
|
if api_type == "new":
|
|
assert entry.state is ConfigEntryState.LOADED
|
|
elif api_type == "old":
|
|
assert entry.state is ConfigEntryState.SETUP_ERROR
|
|
|
|
|
|
@pytest.mark.parametrize("api_type", ["new"])
|
|
async def test_unload_entry(
|
|
hass: HomeAssistant,
|
|
mock_config_entry: MockConfigEntry,
|
|
mocked_fing_agent: AsyncMock,
|
|
) -> None:
|
|
"""Test unload of entry."""
|
|
entry = await init_integration(hass, mock_config_entry, mocked_fing_agent)
|
|
|
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
|
assert entry.state is ConfigEntryState.LOADED
|
|
|
|
assert await hass.config_entries.async_unload(entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert entry.state is ConfigEntryState.NOT_LOADED
|