diff --git a/homeassistant/components/teslemetry/quality_scale.yaml b/homeassistant/components/teslemetry/quality_scale.yaml index de84c847495..b222cac72fd 100644 --- a/homeassistant/components/teslemetry/quality_scale.yaml +++ b/homeassistant/components/teslemetry/quality_scale.yaml @@ -9,9 +9,7 @@ rules: Multiline lambdas should be wrapped in parentheses for readability (e.g. streaming_listener). Use chained comparison: "if 1 < x < 100" instead of "if x > 1 and x < 100". config-flow: done - config-flow-test-coverage: - status: todo - comment: Use mock_setup_entry fixture instead of inline patch + config-flow-test-coverage: done dependency-transparency: done docs-actions: done docs-high-level-description: done diff --git a/tests/components/teslemetry/test_config_flow.py b/tests/components/teslemetry/test_config_flow.py index cef4e10d9ff..0732671adc6 100644 --- a/tests/components/teslemetry/test_config_flow.py +++ b/tests/components/teslemetry/test_config_flow.py @@ -147,6 +147,7 @@ async def test_reauth( @pytest.mark.usefixtures("current_request_with_host") +@pytest.mark.usefixtures("mock_setup_entry") async def test_reauth_account_mismatch( hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator, @@ -170,11 +171,8 @@ async def test_reauth_account_mismatch( old_entry.add_to_hass(hass) # Setup the integration properly to import client credentials - with patch( - "homeassistant.components.teslemetry.async_setup_entry", return_value=True - ): - await hass.config_entries.async_setup(old_entry.entry_id) - await hass.async_block_till_done() + await hass.config_entries.async_setup(old_entry.entry_id) + await hass.async_block_till_done() result = await old_entry.start_reauth_flow(hass) @@ -200,10 +198,7 @@ async def test_reauth_account_mismatch( }, ) - with patch( - "homeassistant.components.teslemetry.async_setup_entry", return_value=True - ): - result = await hass.config_entries.flow.async_configure(result["flow_id"]) + result = await hass.config_entries.flow.async_configure(result["flow_id"]) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "reauth_account_mismatch" @@ -349,6 +344,7 @@ async def test_reconfigure( @pytest.mark.usefixtures("current_request_with_host") +@pytest.mark.usefixtures("mock_setup_entry") async def test_reconfigure_account_mismatch( hass: HomeAssistant, hass_client_no_auth: ClientSessionGenerator, @@ -373,11 +369,8 @@ async def test_reconfigure_account_mismatch( old_entry.add_to_hass(hass) # Setup the integration properly to import client credentials - with patch( - "homeassistant.components.teslemetry.async_setup_entry", return_value=True - ): - await hass.config_entries.async_setup(old_entry.entry_id) - await hass.async_block_till_done() + await hass.config_entries.async_setup(old_entry.entry_id) + await hass.async_block_till_done() client = await hass_client_no_auth() result = await old_entry.start_reconfigure_flow(hass) @@ -392,10 +385,7 @@ async def test_reconfigure_account_mismatch( await client.get(f"/auth/external/callback?code=abcd&state={state}") aioclient_mock.post(TOKEN_URL, json=mock_token_response) - with patch( - "homeassistant.components.teslemetry.async_setup_entry", return_value=True - ): - result = await hass.config_entries.flow.async_configure(result["flow_id"]) + result = await hass.config_entries.flow.async_configure(result["flow_id"]) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "reconfigure_account_mismatch"