From f548d1dba7495ddba09e52378b78748d3f8ef00f Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 5 Oct 2021 11:14:53 +0200 Subject: [PATCH] Prevent opening of sockets in mqtt tests (#57101) --- tests/components/mqtt/test_config_flow.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index e00e959e606..208541d702c 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -29,7 +29,9 @@ def mock_try_connection(): yield mock_try -async def test_user_connection_works(hass, mock_try_connection, mock_finish_setup): +async def test_user_connection_works( + hass, mock_try_connection, mock_finish_setup, mqtt_client_mock +): """Test we can finish a config flow.""" mock_try_connection.return_value = True @@ -76,7 +78,9 @@ async def test_user_connection_fails(hass, mock_try_connection, mock_finish_setu assert len(mock_finish_setup.mock_calls) == 0 -async def test_manual_config_set(hass, mock_try_connection, mock_finish_setup): +async def test_manual_config_set( + hass, mock_try_connection, mock_finish_setup, mqtt_client_mock +): """Test we ignore entry if manual config available.""" assert await async_setup_component(hass, "mqtt", {"mqtt": {"broker": "bla"}}) await hass.async_block_till_done() @@ -128,7 +132,9 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None: assert result.get("reason") == "already_configured" -async def test_hassio_confirm(hass, mock_try_connection, mock_finish_setup): +async def test_hassio_confirm( + hass, mock_try_connection, mock_finish_setup, mqtt_client_mock +): """Test we can finish a config flow.""" mock_try_connection.return_value = True @@ -464,6 +470,9 @@ async def test_option_flow_default_suggested_values( ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + # Make sure all MQTT related jobs are done before ending the test + await hass.async_block_till_done() + async def test_options_user_connection_fails(hass, mock_try_connection): """Test if connection cannot be made."""