From 994e2c544c5ce517755d29509ed46a4d55897a26 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Tue, 30 May 2023 13:11:55 +0200 Subject: [PATCH] Test import already configured --- .../google_translate/test_config_flow.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/components/google_translate/test_config_flow.py b/tests/components/google_translate/test_config_flow.py index 29b0601f38..3dc46547ae 100644 --- a/tests/components/google_translate/test_config_flow.py +++ b/tests/components/google_translate/test_config_flow.py @@ -87,3 +87,23 @@ async def test_import_step(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> CONF_TLD: "de", } assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_import_already_configured( + hass: HomeAssistant, mock_setup_entry: AsyncMock +) -> None: + """Test import step already configured entry.""" + config_entry = MockConfigEntry( + domain=DOMAIN, data={CONF_LANG: "de", CONF_TLD: "de"} + ) + config_entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_IMPORT}, + data={CONF_LANG: "de", CONF_TLD: "de"}, + ) + + assert result["type"] == FlowResultType.ABORT + assert result["reason"] == "already_configured" + assert len(mock_setup_entry.mock_calls) == 0