Axis improve fixture naming (#120844)

This commit is contained in:
Robert Svensson 2024-06-30 14:52:20 +02:00 committed by GitHub
parent d15d001cfc
commit ca7fb906cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 82 additions and 81 deletions

View File

@ -49,8 +49,8 @@ from .const import (
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@pytest.fixture @pytest.fixture(name="mock_setup_entry")
def mock_setup_entry() -> Generator[AsyncMock]: def fixture_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry.""" """Override async_setup_entry."""
with patch( with patch(
"homeassistant.components.axis.async_setup_entry", return_value=True "homeassistant.components.axis.async_setup_entry", return_value=True
@ -62,7 +62,7 @@ def mock_setup_entry() -> Generator[AsyncMock]:
@pytest.fixture(name="config_entry") @pytest.fixture(name="config_entry")
def config_entry_fixture( def fixture_config_entry(
hass: HomeAssistant, 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],
@ -82,13 +82,13 @@ def config_entry_fixture(
@pytest.fixture(name="config_entry_version") @pytest.fixture(name="config_entry_version")
def config_entry_version_fixture() -> int: def fixture_config_entry_version() -> int:
"""Define a config entry version fixture.""" """Define a config entry version fixture."""
return 3 return 3
@pytest.fixture(name="config_entry_data") @pytest.fixture(name="config_entry_data")
def config_entry_data_fixture() -> MappingProxyType[str, Any]: def fixture_config_entry_data() -> MappingProxyType[str, Any]:
"""Define a config entry data fixture.""" """Define a config entry data fixture."""
return { return {
CONF_HOST: DEFAULT_HOST, CONF_HOST: DEFAULT_HOST,
@ -101,7 +101,7 @@ def config_entry_data_fixture() -> MappingProxyType[str, Any]:
@pytest.fixture(name="config_entry_options") @pytest.fixture(name="config_entry_options")
def config_entry_options_fixture() -> MappingProxyType[str, Any]: def fixture_config_entry_options() -> MappingProxyType[str, Any]:
"""Define a config entry options fixture.""" """Define a config entry options fixture."""
return {} return {}
@ -109,8 +109,8 @@ def config_entry_options_fixture() -> MappingProxyType[str, Any]:
# Axis API fixtures # Axis API fixtures
@pytest.fixture(name="mock_vapix_requests") @pytest.fixture(name="mock_requests")
def default_request_fixture( def fixture_request(
respx_mock: respx.MockRouter, respx_mock: respx.MockRouter,
port_management_payload: dict[str, Any], port_management_payload: dict[str, Any],
param_properties_payload: str, param_properties_payload: str,
@ -215,7 +215,7 @@ def api_discovery_items() -> dict[str, Any]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def api_discovery_fixture(api_discovery_items: dict[str, Any]) -> None: def fixture_api_discovery(api_discovery_items: dict[str, Any]) -> None:
"""Apidiscovery mock response.""" """Apidiscovery mock response."""
data = deepcopy(API_DISCOVERY_RESPONSE) data = deepcopy(API_DISCOVERY_RESPONSE)
if api_discovery_items: if api_discovery_items:
@ -224,64 +224,65 @@ def api_discovery_fixture(api_discovery_items: dict[str, Any]) -> None:
@pytest.fixture(name="port_management_payload") @pytest.fixture(name="port_management_payload")
def io_port_management_data_fixture() -> dict[str, Any]: def fixture_io_port_management_data() -> dict[str, Any]:
"""Property parameter data.""" """Property parameter data."""
return PORT_MANAGEMENT_RESPONSE return PORT_MANAGEMENT_RESPONSE
@pytest.fixture(name="param_properties_payload") @pytest.fixture(name="param_properties_payload")
def param_properties_data_fixture() -> str: def fixture_param_properties_data() -> str:
"""Property parameter data.""" """Property parameter data."""
return PROPERTIES_RESPONSE return PROPERTIES_RESPONSE
@pytest.fixture(name="param_ports_payload") @pytest.fixture(name="param_ports_payload")
def param_ports_data_fixture() -> str: def fixture_param_ports_data() -> str:
"""Property parameter data.""" """Property parameter data."""
return PORTS_RESPONSE return PORTS_RESPONSE
@pytest.fixture(name="mqtt_status_code") @pytest.fixture(name="mqtt_status_code")
def mqtt_status_code_fixture() -> int: def fixture_mqtt_status_code() -> int:
"""Property parameter data.""" """Property parameter data."""
return 200 return 200
@pytest.fixture(name="setup_default_vapix_requests") @pytest.fixture(name="mock_default_requests")
def default_vapix_requests_fixture(mock_vapix_requests: Callable[[str], None]) -> None: def fixture_default_requests(mock_requests: Callable[[str], None]) -> None:
"""Mock default Vapix requests responses.""" """Mock default Vapix requests responses."""
mock_vapix_requests(DEFAULT_HOST) mock_requests(DEFAULT_HOST)
@pytest.fixture(name="prepare_config_entry") @pytest.fixture(name="config_entry_factory")
async def prep_config_entry_fixture( async def fixture_config_entry_factory(
hass: HomeAssistant, config_entry: ConfigEntry, setup_default_vapix_requests: None hass: HomeAssistant,
config_entry: ConfigEntry,
mock_requests: Callable[[str], None],
) -> Callable[[], ConfigEntry]: ) -> Callable[[], ConfigEntry]:
"""Fixture factory to set up Axis network device.""" """Fixture factory to set up Axis network device."""
async def __mock_setup_config_entry() -> ConfigEntry: async def __mock_setup_config_entry() -> ConfigEntry:
assert await hass.config_entries.async_setup(config_entry.entry_id) mock_requests(config_entry.data[CONF_HOST])
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
return config_entry return config_entry
return __mock_setup_config_entry return __mock_setup_config_entry
@pytest.fixture(name="setup_config_entry") @pytest.fixture(name="config_entry_setup")
async def setup_config_entry_fixture( async def fixture_config_entry_setup(
hass: HomeAssistant, config_entry: ConfigEntry, setup_default_vapix_requests: None hass: HomeAssistant, config_entry_factory: Callable[[], ConfigEntry]
) -> ConfigEntry: ) -> ConfigEntry:
"""Define a fixture to set up Axis network device.""" """Define a fixture to set up Axis network device."""
assert await hass.config_entries.async_setup(config_entry.entry_id) return await config_entry_factory()
await hass.async_block_till_done()
return config_entry
# RTSP fixtures # RTSP fixtures
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True, name="mock_axis_rtspclient")
def mock_axis_rtspclient() -> Generator[Callable[[dict | None, str], None]]: def fixture_axis_rtspclient() -> Generator[Callable[[dict | None, str], None]]:
"""No real RTSP communication allowed.""" """No real RTSP communication allowed."""
with patch("axis.stream_manager.RTSPClient") as rtsp_client_mock: with patch("axis.stream_manager.RTSPClient") as rtsp_client_mock:
rtsp_client_mock.return_value.session.state = State.STOPPED rtsp_client_mock.return_value.session.state = State.STOPPED
@ -313,8 +314,8 @@ def mock_axis_rtspclient() -> Generator[Callable[[dict | None, str], None]]:
yield make_rtsp_call yield make_rtsp_call
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True, name="mock_rtsp_event")
def mock_rtsp_event( def fixture_rtsp_event(
mock_axis_rtspclient: Callable[[dict | None, str], None], mock_axis_rtspclient: Callable[[dict | None, str], None],
) -> Callable[[str, str, str, str, str, str], None]: ) -> Callable[[str, str, str, str, str, str], None]:
"""Fixture to allow mocking received RTSP events.""" """Fixture to allow mocking received RTSP events."""
@ -366,8 +367,8 @@ def mock_rtsp_event(
return send_event return send_event
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True, name="mock_rtsp_signal_state")
def mock_rtsp_signal_state( def fixture_rtsp_signal_state(
mock_axis_rtspclient: Callable[[dict | None, str], None], mock_axis_rtspclient: Callable[[dict | None, str], None],
) -> Callable[[bool], None]: ) -> Callable[[bool], None]:
"""Fixture to allow mocking RTSP state signalling.""" """Fixture to allow mocking RTSP state signalling."""

View File

@ -173,7 +173,7 @@ from .const import NAME
), ),
], ],
) )
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_binary_sensors( async def test_binary_sensors(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],
@ -225,7 +225,7 @@ async def test_binary_sensors(
}, },
], ],
) )
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_unsupported_events( async def test_unsupported_events(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],

View File

@ -30,7 +30,7 @@ async def test_platform_manually_configured(hass: HomeAssistant) -> None:
assert AXIS_DOMAIN not in hass.data assert AXIS_DOMAIN not in hass.data
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_camera(hass: HomeAssistant) -> None: async def test_camera(hass: HomeAssistant) -> None:
"""Test that Axis camera platform is loaded properly.""" """Test that Axis camera platform is loaded properly."""
assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 1 assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 1
@ -51,7 +51,7 @@ async def test_camera(hass: HomeAssistant) -> None:
@pytest.mark.parametrize("config_entry_options", [{CONF_STREAM_PROFILE: "profile_1"}]) @pytest.mark.parametrize("config_entry_options", [{CONF_STREAM_PROFILE: "profile_1"}])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_camera_with_stream_profile(hass: HomeAssistant) -> None: async def test_camera_with_stream_profile(hass: HomeAssistant) -> None:
"""Test that Axis camera entity is using the correct path with stream profike.""" """Test that Axis camera entity is using the correct path with stream profike."""
assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 1 assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 1
@ -87,8 +87,8 @@ root.Properties.System.SerialNumber={MAC}
@pytest.mark.parametrize("param_properties_payload", [PROPERTY_DATA]) @pytest.mark.parametrize("param_properties_payload", [PROPERTY_DATA])
async def test_camera_disabled( async def test_camera_disabled(
hass: HomeAssistant, prepare_config_entry: Callable[[], ConfigEntry] hass: HomeAssistant, config_entry_factory: Callable[[], ConfigEntry]
) -> None: ) -> None:
"""Test that Axis camera platform is loaded properly but does not create camera entity.""" """Test that Axis camera platform is loaded properly but does not create camera entity."""
await prepare_config_entry() await config_entry_factory()
assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 0 assert len(hass.states.async_entity_ids(CAMERA_DOMAIN)) == 0

View File

@ -55,7 +55,7 @@ async def mock_config_entry_fixture(
return config_entry return config_entry
@pytest.mark.usefixtures("setup_default_vapix_requests", "mock_setup_entry") @pytest.mark.usefixtures("mock_default_requests", "mock_setup_entry")
async def test_flow_manual_configuration(hass: HomeAssistant) -> None: async def test_flow_manual_configuration(hass: HomeAssistant) -> None:
"""Test that config flow works.""" """Test that config flow works."""
MockConfigEntry(domain=AXIS_DOMAIN, source=SOURCE_IGNORE).add_to_hass(hass) MockConfigEntry(domain=AXIS_DOMAIN, source=SOURCE_IGNORE).add_to_hass(hass)
@ -94,7 +94,7 @@ async def test_flow_manual_configuration(hass: HomeAssistant) -> None:
async def test_manual_configuration_update_configuration( async def test_manual_configuration_update_configuration(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_vapix_requests: Callable[[str], None], mock_requests: Callable[[str], None],
) -> None: ) -> None:
"""Test that config flow fails on already configured device.""" """Test that config flow fails on already configured device."""
assert mock_config_entry.data[CONF_HOST] == "1.2.3.4" assert mock_config_entry.data[CONF_HOST] == "1.2.3.4"
@ -106,7 +106,7 @@ async def test_manual_configuration_update_configuration(
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
mock_vapix_requests("2.3.4.5") mock_requests("2.3.4.5")
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
user_input={ user_input={
@ -178,7 +178,7 @@ async def test_flow_fails_cannot_connect(hass: HomeAssistant) -> None:
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@pytest.mark.usefixtures("setup_default_vapix_requests", "mock_setup_entry") @pytest.mark.usefixtures("mock_default_requests", "mock_setup_entry")
async def test_flow_create_entry_multiple_existing_entries_of_same_model( async def test_flow_create_entry_multiple_existing_entries_of_same_model(
hass: HomeAssistant, hass: HomeAssistant,
) -> None: ) -> None:
@ -230,7 +230,7 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model(
async def test_reauth_flow_update_configuration( async def test_reauth_flow_update_configuration(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_vapix_requests: Callable[[str], None], mock_requests: Callable[[str], None],
) -> None: ) -> None:
"""Test that config flow fails on already configured device.""" """Test that config flow fails on already configured device."""
assert mock_config_entry.data[CONF_HOST] == "1.2.3.4" assert mock_config_entry.data[CONF_HOST] == "1.2.3.4"
@ -246,7 +246,7 @@ async def test_reauth_flow_update_configuration(
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
mock_vapix_requests("2.3.4.5") mock_requests("2.3.4.5")
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
user_input={ user_input={
@ -271,7 +271,7 @@ async def test_reauth_flow_update_configuration(
async def test_reconfiguration_flow_update_configuration( async def test_reconfiguration_flow_update_configuration(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_vapix_requests: Callable[[str], None], mock_requests: Callable[[str], None],
) -> None: ) -> None:
"""Test that config flow reconfiguration updates configured device.""" """Test that config flow reconfiguration updates configured device."""
assert mock_config_entry.data[CONF_HOST] == "1.2.3.4" assert mock_config_entry.data[CONF_HOST] == "1.2.3.4"
@ -289,7 +289,7 @@ async def test_reconfiguration_flow_update_configuration(
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
mock_vapix_requests("2.3.4.5") mock_requests("2.3.4.5")
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
user_input={ user_input={
@ -372,7 +372,7 @@ async def test_reconfiguration_flow_update_configuration(
), ),
], ],
) )
@pytest.mark.usefixtures("setup_default_vapix_requests", "mock_setup_entry") @pytest.mark.usefixtures("mock_default_requests", "mock_setup_entry")
async def test_discovery_flow( async def test_discovery_flow(
hass: HomeAssistant, hass: HomeAssistant,
source: str, source: str,
@ -514,7 +514,7 @@ async def test_discovered_device_already_configured(
async def test_discovery_flow_updated_configuration( async def test_discovery_flow_updated_configuration(
hass: HomeAssistant, hass: HomeAssistant,
mock_config_entry: MockConfigEntry, mock_config_entry: MockConfigEntry,
mock_vapix_requests: Callable[[str], None], mock_requests: Callable[[str], None],
source: str, source: str,
discovery_info: BaseServiceInfo, discovery_info: BaseServiceInfo,
expected_port: int, expected_port: int,
@ -529,7 +529,7 @@ async def test_discovery_flow_updated_configuration(
CONF_NAME: NAME, CONF_NAME: NAME,
} }
mock_vapix_requests("2.3.4.5") mock_requests("2.3.4.5")
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN, data=discovery_info, context={"source": source} AXIS_DOMAIN, data=discovery_info, context={"source": source}
) )
@ -646,13 +646,13 @@ async def test_discovery_flow_ignore_link_local_address(
async def test_option_flow( async def test_option_flow(
hass: HomeAssistant, setup_config_entry: ConfigEntry hass: HomeAssistant, config_entry_setup: ConfigEntry
) -> None: ) -> None:
"""Test config flow options.""" """Test config flow options."""
assert CONF_STREAM_PROFILE not in setup_config_entry.options assert CONF_STREAM_PROFILE not in config_entry_setup.options
assert CONF_VIDEO_SOURCE not in setup_config_entry.options assert CONF_VIDEO_SOURCE not in config_entry_setup.options
result = await hass.config_entries.options.async_init(setup_config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry_setup.entry_id)
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "configure_stream" assert result["step_id"] == "configure_stream"
@ -676,5 +676,5 @@ async def test_option_flow(
CONF_STREAM_PROFILE: "profile_1", CONF_STREAM_PROFILE: "profile_1",
CONF_VIDEO_SOURCE: 1, CONF_VIDEO_SOURCE: 1,
} }
assert setup_config_entry.options[CONF_STREAM_PROFILE] == "profile_1" assert config_entry_setup.options[CONF_STREAM_PROFILE] == "profile_1"
assert setup_config_entry.options[CONF_VIDEO_SOURCE] == 1 assert config_entry_setup.options[CONF_VIDEO_SOURCE] == 1

View File

@ -16,11 +16,11 @@ 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,
setup_config_entry: ConfigEntry, config_entry_setup: ConfigEntry,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test config entry diagnostics.""" """Test config entry diagnostics."""
assert ( assert (
await get_diagnostics_for_config_entry(hass, hass_client, setup_config_entry) await get_diagnostics_for_config_entry(hass, hass_client, config_entry_setup)
== snapshot == snapshot
) )

View File

@ -50,11 +50,11 @@ def hass_mock_forward_entry_setup(hass: HomeAssistant) -> Generator[AsyncMock]:
async def test_device_setup( async def test_device_setup(
forward_entry_setups: AsyncMock, forward_entry_setups: AsyncMock,
config_entry_data: MappingProxyType[str, Any], config_entry_data: MappingProxyType[str, Any],
setup_config_entry: ConfigEntry, config_entry_setup: ConfigEntry,
device_registry: dr.DeviceRegistry, device_registry: dr.DeviceRegistry,
) -> None: ) -> None:
"""Successful setup.""" """Successful setup."""
hub = setup_config_entry.runtime_data hub = config_entry_setup.runtime_data
assert hub.api.vapix.firmware_version == "9.10.1" assert hub.api.vapix.firmware_version == "9.10.1"
assert hub.api.vapix.product_number == "M1065-LW" assert hub.api.vapix.product_number == "M1065-LW"
@ -78,9 +78,9 @@ async def test_device_setup(
@pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_BASIC_DEVICE_INFO]) @pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_BASIC_DEVICE_INFO])
async def test_device_info(setup_config_entry: ConfigEntry) -> None: async def test_device_info(config_entry_setup: ConfigEntry) -> None:
"""Verify other path of device information works.""" """Verify other path of device information works."""
hub = setup_config_entry.runtime_data hub = config_entry_setup.runtime_data
assert hub.api.vapix.firmware_version == "9.80.1" assert hub.api.vapix.firmware_version == "9.80.1"
assert hub.api.vapix.product_number == "M1065-LW" assert hub.api.vapix.product_number == "M1065-LW"
@ -89,7 +89,7 @@ async def test_device_info(setup_config_entry: ConfigEntry) -> None:
@pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_MQTT]) @pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_MQTT])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_device_support_mqtt( async def test_device_support_mqtt(
hass: HomeAssistant, mqtt_mock: MqttMockHAClient hass: HomeAssistant, mqtt_mock: MqttMockHAClient
) -> None: ) -> None:
@ -115,7 +115,7 @@ async def test_device_support_mqtt(
@pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_MQTT]) @pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_MQTT])
@pytest.mark.parametrize("mqtt_status_code", [401]) @pytest.mark.parametrize("mqtt_status_code", [401])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_device_support_mqtt_low_privilege(mqtt_mock: MqttMockHAClient) -> None: async def test_device_support_mqtt_low_privilege(mqtt_mock: MqttMockHAClient) -> None:
"""Successful setup.""" """Successful setup."""
mqtt_call = call(f"{MAC}/#", mock.ANY, 0, "utf-8") mqtt_call = call(f"{MAC}/#", mock.ANY, 0, "utf-8")
@ -124,14 +124,14 @@ 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,
setup_config_entry: ConfigEntry, config_entry_setup: ConfigEntry,
mock_vapix_requests: Callable[[str], None], mock_requests: Callable[[str], None],
) -> None: ) -> None:
"""Test update address works.""" """Test update address works."""
hub = setup_config_entry.runtime_data hub = config_entry_setup.runtime_data
assert hub.api.config.host == "1.2.3.4" assert hub.api.config.host == "1.2.3.4"
mock_vapix_requests("2.3.4.5") mock_requests("2.3.4.5")
await hass.config_entries.flow.async_init( await hass.config_entries.flow.async_init(
AXIS_DOMAIN, AXIS_DOMAIN,
data=zeroconf.ZeroconfServiceInfo( data=zeroconf.ZeroconfServiceInfo(
@ -150,7 +150,7 @@ async def test_update_address(
assert hub.api.config.host == "2.3.4.5" assert hub.api.config.host == "2.3.4.5"
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_device_unavailable( async def test_device_unavailable(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],
@ -187,7 +187,7 @@ async def test_device_unavailable(
assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.{NAME}_sound_1").state == STATE_OFF assert hass.states.get(f"{BINARY_SENSOR_DOMAIN}.{NAME}_sound_1").state == STATE_OFF
@pytest.mark.usefixtures("setup_default_vapix_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: ConfigEntry
) -> None: ) -> None:
@ -198,7 +198,7 @@ async def test_device_not_accessible(
assert hass.data[AXIS_DOMAIN] == {} assert hass.data[AXIS_DOMAIN] == {}
@pytest.mark.usefixtures("setup_default_vapix_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: ConfigEntry
) -> None: ) -> None:
@ -215,7 +215,7 @@ async def test_device_trigger_reauth_flow(
assert hass.data[AXIS_DOMAIN] == {} assert hass.data[AXIS_DOMAIN] == {}
@pytest.mark.usefixtures("setup_default_vapix_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: ConfigEntry
) -> None: ) -> None:

View File

@ -9,9 +9,9 @@ from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
async def test_setup_entry(setup_config_entry: ConfigEntry) -> None: async def test_setup_entry(config_entry_setup: ConfigEntry) -> None:
"""Test successful setup of entry.""" """Test successful setup of entry."""
assert setup_config_entry.state is ConfigEntryState.LOADED assert config_entry_setup.state is ConfigEntryState.LOADED
async def test_setup_entry_fails( async def test_setup_entry_fails(
@ -30,13 +30,13 @@ async def test_setup_entry_fails(
async def test_unload_entry( async def test_unload_entry(
hass: HomeAssistant, setup_config_entry: ConfigEntry hass: HomeAssistant, config_entry_setup: ConfigEntry
) -> None: ) -> None:
"""Test successful unload of entry.""" """Test successful unload of entry."""
assert setup_config_entry.state is ConfigEntryState.LOADED assert config_entry_setup.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(setup_config_entry.entry_id) assert await hass.config_entries.async_unload(config_entry_setup.entry_id)
assert setup_config_entry.state is ConfigEntryState.NOT_LOADED assert config_entry_setup.state is ConfigEntryState.NOT_LOADED
@pytest.mark.parametrize("config_entry_version", [1]) @pytest.mark.parametrize("config_entry_version", [1])

View File

@ -69,7 +69,7 @@ def light_control_fixture(light_control_items: list[dict[str, Any]]) -> None:
@pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_LIGHT_CONTROL]) @pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_LIGHT_CONTROL])
@pytest.mark.parametrize("light_control_items", [[]]) @pytest.mark.parametrize("light_control_items", [[]])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_no_light_entity_without_light_control_representation( async def test_no_light_entity_without_light_control_representation(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],
@ -88,7 +88,7 @@ async def test_no_light_entity_without_light_control_representation(
@pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_LIGHT_CONTROL]) @pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_LIGHT_CONTROL])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_lights( async def test_lights(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],

View File

@ -30,7 +30,7 @@ root.IOPort.I1.Output.Active=open
@pytest.mark.parametrize("param_ports_payload", [PORT_DATA]) @pytest.mark.parametrize("param_ports_payload", [PORT_DATA])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_switches_with_port_cgi( async def test_switches_with_port_cgi(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],
@ -115,7 +115,7 @@ PORT_MANAGEMENT_RESPONSE = {
@pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_PORT_MANAGEMENT]) @pytest.mark.parametrize("api_discovery_items", [API_DISCOVERY_PORT_MANAGEMENT])
@pytest.mark.parametrize("port_management_payload", [PORT_MANAGEMENT_RESPONSE]) @pytest.mark.parametrize("port_management_payload", [PORT_MANAGEMENT_RESPONSE])
@pytest.mark.usefixtures("setup_config_entry") @pytest.mark.usefixtures("config_entry_setup")
async def test_switches_with_port_management( async def test_switches_with_port_management(
hass: HomeAssistant, hass: HomeAssistant,
mock_rtsp_event: Callable[[str, str, str, str, str, str], None], mock_rtsp_event: Callable[[str, str, str, str, str, str], None],