mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 00:20:30 +01:00
Fix lingering tasks in nest tests (#166959)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -203,6 +203,16 @@ def mock_subscriber() -> YieldFixture[AsyncMock]:
|
||||
yield mock_subscriber
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_subscriber_refresh() -> YieldFixture[None]:
|
||||
"""Fixture for mocking subscriber refresh."""
|
||||
with patch(
|
||||
"homeassistant.components.nest.api.GoogleNestSubscriber._async_run_refresh",
|
||||
new=AsyncMock(),
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def device_id() -> str:
|
||||
"""Fixture to set default device id used when creating devices."""
|
||||
|
||||
@@ -497,6 +497,7 @@ def mock_pubsub_api_responses_fixture(
|
||||
"user-managed-topic-existing-subscription",
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -641,6 +642,7 @@ async def test_full_flow(
|
||||
"user-managed-topic-existing-subscription",
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_config_flow_restart(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -701,6 +703,7 @@ async def test_config_flow_restart(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
@pytest.mark.parametrize(("sdm_managed_topic"), [True])
|
||||
async def test_config_flow_wrong_project_id(
|
||||
hass: HomeAssistant,
|
||||
@@ -763,6 +766,7 @@ async def test_config_flow_wrong_project_id(
|
||||
("create_subscription_status"),
|
||||
[HTTPStatus.NOT_FOUND, HTTPStatus.INTERNAL_SERVER_ERROR, HTTPStatus.UNAUTHORIZED],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_config_flow_pubsub_create_subscription_failure(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -872,6 +876,7 @@ async def test_config_flow_pubsub_create_subscription_failure(
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_multiple_config_entries(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1026,6 +1031,7 @@ async def test_pubsub_subscriber_config_entry_reauth(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("sdm_managed_topic"), [(True)])
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_config_entry_title_from_home(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1078,6 +1084,7 @@ async def test_config_entry_title_from_home(
|
||||
(False, {"selected_topic": "create_new_topic"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_config_entry_title_multiple_homes(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1159,6 +1166,7 @@ async def test_title_failure_fallback(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("sdm_managed_topic"), [(True)])
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_structure_missing_trait(
|
||||
hass: HomeAssistant, oauth: OAuthFixture, auth: FakeAuth
|
||||
) -> None:
|
||||
@@ -1312,6 +1320,7 @@ async def test_dhcp_discovery_already_setup(
|
||||
"user-managed-select-existing-subscription",
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_dhcp_discovery_with_creds(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1407,6 +1416,7 @@ async def test_token_error(
|
||||
)
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_existing_topic_and_subscription(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1448,6 +1458,7 @@ async def test_existing_topic_and_subscription(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_no_eligible_topics(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1520,6 +1531,7 @@ async def test_list_topics_failure(
|
||||
assert result.get("reason") == "pubsub_api_error"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_create_topic_failed(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
@@ -1607,6 +1619,7 @@ async def test_create_topic_failed(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("sdm_managed_topic"), [(True)])
|
||||
@pytest.mark.usefixtures("mock_subscriber_refresh")
|
||||
async def test_list_subscriptions_failure(
|
||||
hass: HomeAssistant,
|
||||
oauth: OAuthFixture,
|
||||
|
||||
Reference in New Issue
Block a user