From 7982f713e156a44439f35edaf87a536305e59997 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:53:08 +0100 Subject: [PATCH] Fix lingering tasks in plex (#89282) * Cleanup expected_lingering_tasks in plex * Adjust --- tests/components/plex/test_config_flow.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/components/plex/test_config_flow.py b/tests/components/plex/test_config_flow.py index 0bc2d04b41a..beb454e2e9c 100644 --- a/tests/components/plex/test_config_flow.py +++ b/tests/components/plex/test_config_flow.py @@ -168,10 +168,11 @@ async def test_no_servers_found( assert result["errors"]["base"] == "no_servers" -# This tests needs to be adjusted to remove lingering tasks -@pytest.mark.parametrize("expected_lingering_tasks", [True]) async def test_single_available_server( - hass: HomeAssistant, mock_plex_calls, current_request_with_host: None + hass: HomeAssistant, + mock_plex_calls, + current_request_with_host: None, + mock_setup_entry: AsyncMock, ) -> None: """Test creating an entry with one server available.""" result = await hass.config_entries.flow.async_init( @@ -205,17 +206,16 @@ async def test_single_available_server( ) assert result["data"][PLEX_SERVER_CONFIG][CONF_TOKEN] == MOCK_TOKEN - await hass.config_entries.async_unload(result["result"].entry_id) + mock_setup_entry.assert_called_once() -# This tests needs to be adjusted to remove lingering tasks -@pytest.mark.parametrize("expected_lingering_tasks", [True]) async def test_multiple_servers_with_selection( hass: HomeAssistant, mock_plex_calls, requests_mock: requests_mock.Mocker, plextv_resources_two_servers, current_request_with_host: None, + mock_setup_entry: AsyncMock, ) -> None: """Test creating an entry with multiple servers available.""" result = await hass.config_entries.flow.async_init( @@ -262,17 +262,16 @@ async def test_multiple_servers_with_selection( ) assert result["data"][PLEX_SERVER_CONFIG][CONF_TOKEN] == MOCK_TOKEN - await hass.config_entries.async_unload(result["result"].entry_id) + mock_setup_entry.assert_called_once() -# This tests needs to be adjusted to remove lingering tasks -@pytest.mark.parametrize("expected_lingering_tasks", [True]) async def test_adding_last_unconfigured_server( hass: HomeAssistant, mock_plex_calls, requests_mock: requests_mock.Mocker, plextv_resources_two_servers, current_request_with_host: None, + mock_setup_entry: AsyncMock, ) -> None: """Test automatically adding last unconfigured server when multiple servers on account.""" MockConfigEntry( @@ -319,7 +318,7 @@ async def test_adding_last_unconfigured_server( ) assert result["data"][PLEX_SERVER_CONFIG][CONF_TOKEN] == MOCK_TOKEN - await hass.config_entries.async_unload(result["result"].entry_id) + assert mock_setup_entry.call_count == 2 async def test_all_available_servers_configured(