From 22b2c588ebb5ef858aa100196fd8dc798abf2bfa Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 13 Dec 2023 11:23:38 +0100 Subject: [PATCH] Use issue registry fixture (#105633) --- tests/components/cloud/test_repairs.py | 12 +++++------- tests/components/harmony/test_switch.py | 2 +- tests/components/shelly/test_climate.py | 7 ++++--- tests/components/shelly/test_coordinator.py | 7 ++++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/components/cloud/test_repairs.py b/tests/components/cloud/test_repairs.py index 8d890a503e1..0e662c30ee7 100644 --- a/tests/components/cloud/test_repairs.py +++ b/tests/components/cloud/test_repairs.py @@ -21,10 +21,9 @@ from tests.typing import ClientSessionGenerator async def test_do_not_create_repair_issues_at_startup_if_not_logged_in( hass: HomeAssistant, + issue_registry: ir.IssueRegistry, ) -> None: """Test that we create repair issue at startup if we are logged in.""" - issue_registry: ir.IssueRegistry = ir.async_get(hass) - with patch("homeassistant.components.cloud.Cloud.is_logged_in", False): await mock_cloud(hass) @@ -40,9 +39,9 @@ async def test_create_repair_issues_at_startup_if_logged_in( hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, mock_auth: Generator[None, AsyncMock, None], + issue_registry: ir.IssueRegistry, ): """Test that we create repair issue at startup if we are logged in.""" - issue_registry: ir.IssueRegistry = ir.async_get(hass) aioclient_mock.get( "https://accounts.nabucasa.com/payments/subscription_info", json={"provider": "legacy"}, @@ -61,9 +60,9 @@ async def test_create_repair_issues_at_startup_if_logged_in( async def test_legacy_subscription_delete_issue_if_no_longer_legacy( hass: HomeAssistant, + issue_registry: ir.IssueRegistry, ) -> None: """Test that we delete the legacy subscription issue if no longer legacy.""" - issue_registry: ir.IssueRegistry = ir.async_get(hass) cloud_repairs.async_manage_legacy_subscription_issue(hass, {"provider": "legacy"}) assert issue_registry.async_get_issue( domain="cloud", issue_id="legacy_subscription" @@ -80,9 +79,9 @@ async def test_legacy_subscription_repair_flow( aioclient_mock: AiohttpClientMocker, mock_auth: Generator[None, AsyncMock, None], hass_client: ClientSessionGenerator, + issue_registry: ir.IssueRegistry, ): """Test desired flow of the fix flow for legacy subscription.""" - issue_registry: ir.IssueRegistry = ir.async_get(hass) aioclient_mock.get( "https://accounts.nabucasa.com/payments/subscription_info", json={"provider": None}, @@ -167,6 +166,7 @@ async def test_legacy_subscription_repair_flow_timeout( hass_client: ClientSessionGenerator, mock_auth: Generator[None, AsyncMock, None], aioclient_mock: AiohttpClientMocker, + issue_registry: ir.IssueRegistry, ): """Test timeout flow of the fix flow for legacy subscription.""" aioclient_mock.post( @@ -174,8 +174,6 @@ async def test_legacy_subscription_repair_flow_timeout( status=403, ) - issue_registry: ir.IssueRegistry = ir.async_get(hass) - cloud_repairs.async_manage_legacy_subscription_issue(hass, {"provider": "legacy"}) repair_issue = issue_registry.async_get_issue( domain="cloud", issue_id="legacy_subscription" diff --git a/tests/components/harmony/test_switch.py b/tests/components/harmony/test_switch.py index 59e5a7c7fc8..f843ab4deca 100644 --- a/tests/components/harmony/test_switch.py +++ b/tests/components/harmony/test_switch.py @@ -146,6 +146,7 @@ async def test_create_issue( hass: HomeAssistant, mock_write_config, entity_registry_enabled_by_default: None, + issue_registry: ir.IssueRegistry, ) -> None: """Test we create an issue when an automation or script is using a deprecated entity.""" assert await async_setup_component( @@ -186,7 +187,6 @@ async def test_create_issue( assert automations_with_entity(hass, ENTITY_WATCH_TV)[0] == "automation.test" assert scripts_with_entity(hass, ENTITY_WATCH_TV)[0] == "script.test" - issue_registry: ir.IssueRegistry = ir.async_get(hass) assert issue_registry.async_get_issue(DOMAIN, "deprecated_switches") assert issue_registry.async_get_issue( diff --git a/tests/components/shelly/test_climate.py b/tests/components/shelly/test_climate.py index fe518b8509c..f52b542b389 100644 --- a/tests/components/shelly/test_climate.py +++ b/tests/components/shelly/test_climate.py @@ -503,11 +503,12 @@ async def test_block_restored_climate_auth_error( async def test_device_not_calibrated( - hass: HomeAssistant, mock_block_device, monkeypatch + hass: HomeAssistant, + mock_block_device, + monkeypatch, + issue_registry: ir.IssueRegistry, ) -> None: """Test to create an issue when the device is not calibrated.""" - issue_registry: ir.IssueRegistry = ir.async_get(hass) - await init_integration(hass, 1, sleep_period=1000, model=MODEL_VALVE) # Make device online diff --git a/tests/components/shelly/test_coordinator.py b/tests/components/shelly/test_coordinator.py index e73168c6b20..27aa8710621 100644 --- a/tests/components/shelly/test_coordinator.py +++ b/tests/components/shelly/test_coordinator.py @@ -250,11 +250,12 @@ async def test_block_sleeping_device_no_periodic_updates( async def test_block_device_push_updates_failure( - hass: HomeAssistant, mock_block_device, monkeypatch + hass: HomeAssistant, + mock_block_device, + monkeypatch, + issue_registry: ir.IssueRegistry, ) -> None: """Test block device with push updates failure.""" - issue_registry: ir.IssueRegistry = ir.async_get(hass) - await init_integration(hass, 1) # Updates with COAP_REPLAY type should create an issue