mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Move mock_hass_config fixture to decorator (#118807)
This commit is contained in:
parent
2ac5f8db06
commit
089874f818
@ -266,11 +266,11 @@ async def test_send_usage(
|
|||||||
assert snapshot == submitted_data
|
assert snapshot == submitted_data
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_usage_with_supervisor(
|
async def test_send_usage_with_supervisor(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test send usage with supervisor preferences are defined."""
|
"""Test send usage with supervisor preferences are defined."""
|
||||||
@ -359,11 +359,9 @@ async def test_send_statistics(
|
|||||||
assert snapshot == submitted_data
|
assert snapshot == submitted_data
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_statistics_one_integration_fails(
|
async def test_send_statistics_one_integration_fails(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
caplog: pytest.LogCaptureFixture,
|
|
||||||
aioclient_mock: AiohttpClientMocker,
|
|
||||||
mock_hass_config: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test send statistics preferences are defined."""
|
"""Test send statistics preferences are defined."""
|
||||||
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
|
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
|
||||||
@ -384,11 +382,11 @@ async def test_send_statistics_one_integration_fails(
|
|||||||
assert post_call[2]["integration_count"] == 0
|
assert post_call[2]["integration_count"] == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_statistics_disabled_integration(
|
async def test_send_statistics_disabled_integration(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
installation_type_mock: Generator[Any, Any, None],
|
installation_type_mock: Generator[Any, Any, None],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -422,11 +420,11 @@ async def test_send_statistics_disabled_integration(
|
|||||||
assert snapshot == submitted_data
|
assert snapshot == submitted_data
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_statistics_ignored_integration(
|
async def test_send_statistics_ignored_integration(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
installation_type_mock: Generator[Any, Any, None],
|
installation_type_mock: Generator[Any, Any, None],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -466,11 +464,9 @@ async def test_send_statistics_ignored_integration(
|
|||||||
assert snapshot == submitted_data
|
assert snapshot == submitted_data
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_statistics_async_get_integration_unknown_exception(
|
async def test_send_statistics_async_get_integration_unknown_exception(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
caplog: pytest.LogCaptureFixture,
|
|
||||||
aioclient_mock: AiohttpClientMocker,
|
|
||||||
mock_hass_config: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test send statistics preferences are defined."""
|
"""Test send statistics preferences are defined."""
|
||||||
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
|
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
|
||||||
@ -490,11 +486,11 @@ async def test_send_statistics_async_get_integration_unknown_exception(
|
|||||||
await analytics.send_analytics()
|
await analytics.send_analytics()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_statistics_with_supervisor(
|
async def test_send_statistics_with_supervisor(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test send statistics preferences are defined."""
|
"""Test send statistics preferences are defined."""
|
||||||
@ -655,10 +651,10 @@ async def test_nightly_endpoint(
|
|||||||
assert str(payload[1]) == ANALYTICS_ENDPOINT_URL
|
assert str(payload[1]) == ANALYTICS_ENDPOINT_URL
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_with_no_energy(
|
async def test_send_with_no_energy(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
installation_type_mock: Generator[Any, Any, None],
|
installation_type_mock: Generator[Any, Any, None],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
@ -692,11 +688,10 @@ async def test_send_with_no_energy(
|
|||||||
assert snapshot == submitted_data
|
assert snapshot == submitted_data
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("recorder_mock", "mock_hass_config")
|
||||||
async def test_send_with_no_energy_config(
|
async def test_send_with_no_energy_config(
|
||||||
recorder_mock: Recorder,
|
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
installation_type_mock: Generator[Any, Any, None],
|
installation_type_mock: Generator[Any, Any, None],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
@ -725,11 +720,10 @@ async def test_send_with_no_energy_config(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("recorder_mock", "mock_hass_config")
|
||||||
async def test_send_with_energy_config(
|
async def test_send_with_energy_config(
|
||||||
recorder_mock: Recorder,
|
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
installation_type_mock: Generator[Any, Any, None],
|
installation_type_mock: Generator[Any, Any, None],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
@ -758,11 +752,11 @@ async def test_send_with_energy_config(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_send_usage_with_certificate(
|
async def test_send_usage_with_certificate(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
installation_type_mock: Generator[Any, Any, None],
|
installation_type_mock: Generator[Any, Any, None],
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -836,11 +830,11 @@ async def test_send_with_problems_loading_yaml(
|
|||||||
assert len(aioclient_mock.mock_calls) == 0
|
assert len(aioclient_mock.mock_calls) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_timeout_while_sending(
|
async def test_timeout_while_sending(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
mock_hass_config: None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test timeout error while sending analytics."""
|
"""Test timeout error while sending analytics."""
|
||||||
analytics = Analytics(hass)
|
analytics = Analytics(hass)
|
||||||
|
@ -27,8 +27,9 @@ from tests.common import async_mock_service
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_if_fires_on_hass_start(
|
async def test_if_fires_on_hass_start(
|
||||||
hass: HomeAssistant, mock_hass_config: None, hass_config: ConfigType
|
hass: HomeAssistant, hass_config: ConfigType
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the firing when Home Assistant starts."""
|
"""Test the firing when Home Assistant starts."""
|
||||||
calls = async_mock_service(hass, "test", "automation")
|
calls = async_mock_service(hass, "test", "automation")
|
||||||
|
@ -31,12 +31,12 @@ from tests.typing import ClientSessionGenerator
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("hass_config", [{}])
|
@pytest.mark.parametrize("hass_config", [{}])
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_diagnostics(
|
async def test_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
knx: KNXTestKit,
|
knx: KNXTestKit,
|
||||||
mock_hass_config: None,
|
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test diagnostics."""
|
"""Test diagnostics."""
|
||||||
@ -51,9 +51,9 @@ async def test_diagnostics(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("hass_config", [{"knx": {"wrong_key": {}}}])
|
@pytest.mark.parametrize("hass_config", [{"knx": {"wrong_key": {}}}])
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_diagnostic_config_error(
|
async def test_diagnostic_config_error(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_hass_config: None,
|
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
knx: KNXTestKit,
|
knx: KNXTestKit,
|
||||||
@ -72,10 +72,10 @@ async def test_diagnostic_config_error(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("hass_config", [{}])
|
@pytest.mark.parametrize("hass_config", [{}])
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_diagnostic_redact(
|
async def test_diagnostic_redact(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_hass_config: None,
|
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test diagnostics redacting data."""
|
"""Test diagnostics redacting data."""
|
||||||
@ -107,12 +107,12 @@ async def test_diagnostic_redact(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("hass_config", [{}])
|
@pytest.mark.parametrize("hass_config", [{}])
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_diagnostics_project(
|
async def test_diagnostics_project(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
knx: KNXTestKit,
|
knx: KNXTestKit,
|
||||||
mock_hass_config: None,
|
|
||||||
load_knxproj: None,
|
load_knxproj: None,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -928,9 +928,9 @@ def test_entity_device_info_schema() -> None:
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures("mock_hass_config")
|
||||||
async def test_handle_logging_on_writing_the_entity_state(
|
async def test_handle_logging_on_writing_the_entity_state(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_hass_config: None,
|
|
||||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user