Skip to content

Commit

Permalink
Replace ConfigEntry with MockConfigEntry in Axis tests (home-assistan…
Browse files Browse the repository at this point in the history
…t#122629)

* Remove unused fixtures in Axis tests

* Replace ConfigEntry with MockConfigEntry
  • Loading branch information
Kane610 authored Jul 26, 2024
1 parent 51d5e21 commit c9b81a5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
1 change: 0 additions & 1 deletion tests/components/axis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/components/axis/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -16,7 +16,7 @@
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."""
Expand Down
14 changes: 7 additions & 7 deletions tests/components/axis/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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
Expand All @@ -28,15 +28,15 @@
NAME,
)

from tests.common import async_fire_mqtt_message
from tests.common import MockConfigEntry, async_fire_mqtt_message
from tests.typing import MqttMockHAClient


@pytest.mark.parametrize(
"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:
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions tests/components/axis/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c9b81a5

Please sign in to comment.