Replace ConfigEntry with MockConfigEntry in Axis tests (#122629)

* Remove unused fixtures in Axis tests

* Replace ConfigEntry with MockConfigEntry
This commit is contained in:
Robert Svensson 2024-07-26 09:48:37 +02:00 committed by GitHub
parent 51d5e21203
commit c9b81a5c04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 15 deletions

View File

@ -85,7 +85,6 @@ def fixture_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture(name="config_entry")
def fixture_config_entry(
hass: HomeAssistant,
config_entry_data: MappingProxyType[str, Any],
config_entry_options: MappingProxyType[str, Any],
config_entry_version: int,

View File

@ -3,11 +3,11 @@
import pytest
from syrupy import SnapshotAssertion
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
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.typing import ClientSessionGenerator
@ -16,7 +16,7 @@ from tests.typing import ClientSessionGenerator
async def test_entry_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
config_entry_setup: ConfigEntry,
config_entry_setup: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test config entry diagnostics."""

View File

@ -14,7 +14,7 @@ from syrupy import SnapshotAssertion
from homeassistant.components import axis, zeroconf
from homeassistant.components.axis.const import DOMAIN as AXIS_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.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
@ -28,7 +28,7 @@ from .const import (
NAME,
)
from tests.common import async_fire_mqtt_message
from tests.common import MockConfigEntry, async_fire_mqtt_message
from tests.typing import MqttMockHAClient
@ -36,7 +36,7 @@ from tests.typing import MqttMockHAClient
"api_discovery_items", [({}), (API_DISCOVERY_BASIC_DEVICE_INFO)]
)
async def test_device_registry_entry(
config_entry_setup: ConfigEntry,
config_entry_setup: MockConfigEntry,
device_registry: dr.DeviceRegistry,
snapshot: SnapshotAssertion,
) -> None:
@ -83,7 +83,7 @@ async def test_device_support_mqtt_low_privilege(mqtt_mock: MqttMockHAClient) ->
async def test_update_address(
hass: HomeAssistant,
config_entry_setup: ConfigEntry,
config_entry_setup: MockConfigEntry,
mock_requests: Callable[[str], None],
) -> None:
"""Test update address works."""
@ -148,7 +148,7 @@ async def test_device_unavailable(
@pytest.mark.usefixtures("mock_default_requests")
async def test_device_not_accessible(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Failed setup schedules a retry of setup."""
config_entry.add_to_hass(hass)
@ -160,7 +160,7 @@ async def test_device_not_accessible(
@pytest.mark.usefixtures("mock_default_requests")
async def test_device_trigger_reauth_flow(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Failed authentication trigger a reauthentication flow."""
config_entry.add_to_hass(hass)
@ -178,7 +178,7 @@ async def test_device_trigger_reauth_flow(
@pytest.mark.usefixtures("mock_default_requests")
async def test_device_unknown_error(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Unknown errors are handled."""
config_entry.add_to_hass(hass)

View File

@ -5,17 +5,19 @@ from unittest.mock import AsyncMock, Mock, patch
import pytest
from homeassistant.components import axis
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.config_entries import ConfigEntryState
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."""
assert config_entry_setup.state is ConfigEntryState.LOADED
async def test_setup_entry_fails(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Test successful setup of entry."""
config_entry.add_to_hass(hass)
@ -32,7 +34,7 @@ async def test_setup_entry_fails(
async def test_unload_entry(
hass: HomeAssistant, config_entry_setup: ConfigEntry
hass: HomeAssistant, config_entry_setup: MockConfigEntry
) -> None:
"""Test successful unload of entry."""
assert config_entry_setup.state is ConfigEntryState.LOADED
@ -42,7 +44,9 @@ async def test_unload_entry(
@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."""
config_entry.add_to_hass(hass)
assert config_entry.version == 1