mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Replace ConfigEntry with MockConfigEntry in Axis tests (#122629)
* Remove unused fixtures in Axis tests * Replace ConfigEntry with MockConfigEntry
This commit is contained in:
parent
51d5e21203
commit
c9b81a5c04
@ -85,7 +85,6 @@ def fixture_setup_entry() -> Generator[AsyncMock]:
|
|||||||
|
|
||||||
@pytest.fixture(name="config_entry")
|
@pytest.fixture(name="config_entry")
|
||||||
def fixture_config_entry(
|
def fixture_config_entry(
|
||||||
hass: HomeAssistant,
|
|
||||||
config_entry_data: MappingProxyType[str, Any],
|
config_entry_data: MappingProxyType[str, Any],
|
||||||
config_entry_options: MappingProxyType[str, Any],
|
config_entry_options: MappingProxyType[str, Any],
|
||||||
config_entry_version: int,
|
config_entry_version: int,
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import API_DISCOVERY_BASIC_DEVICE_INFO
|
from .const import API_DISCOVERY_BASIC_DEVICE_INFO
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ from tests.typing import ClientSessionGenerator
|
|||||||
async def test_entry_diagnostics(
|
async def test_entry_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
config_entry_setup: ConfigEntry,
|
config_entry_setup: MockConfigEntry,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config entry diagnostics."""
|
"""Test config entry diagnostics."""
|
||||||
|
@ -14,7 +14,7 @@ from syrupy import SnapshotAssertion
|
|||||||
from homeassistant.components import axis, zeroconf
|
from homeassistant.components import axis, zeroconf
|
||||||
from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
|
from homeassistant.components.axis.const import DOMAIN as AXIS_DOMAIN
|
||||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_ZEROCONF, ConfigEntry
|
from homeassistant.config_entries import SOURCE_ZEROCONF
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
@ -28,7 +28,7 @@ from .const import (
|
|||||||
NAME,
|
NAME,
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import async_fire_mqtt_message
|
from tests.common import MockConfigEntry, async_fire_mqtt_message
|
||||||
from tests.typing import MqttMockHAClient
|
from tests.typing import MqttMockHAClient
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ from tests.typing import MqttMockHAClient
|
|||||||
"api_discovery_items", [({}), (API_DISCOVERY_BASIC_DEVICE_INFO)]
|
"api_discovery_items", [({}), (API_DISCOVERY_BASIC_DEVICE_INFO)]
|
||||||
)
|
)
|
||||||
async def test_device_registry_entry(
|
async def test_device_registry_entry(
|
||||||
config_entry_setup: ConfigEntry,
|
config_entry_setup: MockConfigEntry,
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -83,7 +83,7 @@ async def test_device_support_mqtt_low_privilege(mqtt_mock: MqttMockHAClient) ->
|
|||||||
|
|
||||||
async def test_update_address(
|
async def test_update_address(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry_setup: ConfigEntry,
|
config_entry_setup: MockConfigEntry,
|
||||||
mock_requests: Callable[[str], None],
|
mock_requests: Callable[[str], None],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test update address works."""
|
"""Test update address works."""
|
||||||
@ -148,7 +148,7 @@ async def test_device_unavailable(
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("mock_default_requests")
|
@pytest.mark.usefixtures("mock_default_requests")
|
||||||
async def test_device_not_accessible(
|
async def test_device_not_accessible(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Failed setup schedules a retry of setup."""
|
"""Failed setup schedules a retry of setup."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
@ -160,7 +160,7 @@ async def test_device_not_accessible(
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("mock_default_requests")
|
@pytest.mark.usefixtures("mock_default_requests")
|
||||||
async def test_device_trigger_reauth_flow(
|
async def test_device_trigger_reauth_flow(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Failed authentication trigger a reauthentication flow."""
|
"""Failed authentication trigger a reauthentication flow."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
@ -178,7 +178,7 @@ async def test_device_trigger_reauth_flow(
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("mock_default_requests")
|
@pytest.mark.usefixtures("mock_default_requests")
|
||||||
async def test_device_unknown_error(
|
async def test_device_unknown_error(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Unknown errors are handled."""
|
"""Unknown errors are handled."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
@ -5,17 +5,19 @@ from unittest.mock import AsyncMock, Mock, patch
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import axis
|
from homeassistant.components import axis
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
async def test_setup_entry(config_entry_setup: ConfigEntry) -> None:
|
|
||||||
|
async def test_setup_entry(config_entry_setup: MockConfigEntry) -> None:
|
||||||
"""Test successful setup of entry."""
|
"""Test successful setup of entry."""
|
||||||
assert config_entry_setup.state is ConfigEntryState.LOADED
|
assert config_entry_setup.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_entry_fails(
|
async def test_setup_entry_fails(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test successful setup of entry."""
|
"""Test successful setup of entry."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
@ -32,7 +34,7 @@ async def test_setup_entry_fails(
|
|||||||
|
|
||||||
|
|
||||||
async def test_unload_entry(
|
async def test_unload_entry(
|
||||||
hass: HomeAssistant, config_entry_setup: ConfigEntry
|
hass: HomeAssistant, config_entry_setup: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test successful unload of entry."""
|
"""Test successful unload of entry."""
|
||||||
assert config_entry_setup.state is ConfigEntryState.LOADED
|
assert config_entry_setup.state is ConfigEntryState.LOADED
|
||||||
@ -42,7 +44,9 @@ async def test_unload_entry(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("config_entry_version", [1])
|
@pytest.mark.parametrize("config_entry_version", [1])
|
||||||
async def test_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
async def test_migrate_entry(
|
||||||
|
hass: HomeAssistant, config_entry: MockConfigEntry
|
||||||
|
) -> None:
|
||||||
"""Test successful migration of entry data."""
|
"""Test successful migration of entry data."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
assert config_entry.version == 1
|
assert config_entry.version == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user