From 325733158d6709783b860cdf626311812bbd64f8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 12 Apr 2023 08:29:13 -0400 Subject: [PATCH] Allow multiple instances for OpenAI (#90609) * Allow multiple instances for OpenAI * Add test --- .../openai_conversation/config_flow.py | 3 --- .../openai_conversation/strings.json | 3 --- .../openai_conversation/test_config_flow.py | 18 ++++++++---------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/openai_conversation/config_flow.py b/homeassistant/components/openai_conversation/config_flow.py index 892d794bcaf..b391f531eb1 100644 --- a/homeassistant/components/openai_conversation/config_flow.py +++ b/homeassistant/components/openai_conversation/config_flow.py @@ -72,9 +72,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> FlowResult: """Handle the initial step.""" - if self._async_current_entries(): - return self.async_abort(reason="single_instance_allowed") - if user_input is None: return self.async_show_form( step_id="user", data_schema=STEP_USER_DATA_SCHEMA diff --git a/homeassistant/components/openai_conversation/strings.json b/homeassistant/components/openai_conversation/strings.json index f7af4618a9d..9583e759bd2 100644 --- a/homeassistant/components/openai_conversation/strings.json +++ b/homeassistant/components/openai_conversation/strings.json @@ -11,9 +11,6 @@ "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", "unknown": "[%key:common::config_flow::error::unknown%]" - }, - "abort": { - "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" } }, "options": { diff --git a/tests/components/openai_conversation/test_config_flow.py b/tests/components/openai_conversation/test_config_flow.py index 4ce677d8cca..471be8035b6 100644 --- a/tests/components/openai_conversation/test_config_flow.py +++ b/tests/components/openai_conversation/test_config_flow.py @@ -13,20 +13,18 @@ from homeassistant.components.openai_conversation.const import ( from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType - -async def test_single_instance_allowed( - hass: HomeAssistant, mock_config_entry: config_entries.ConfigEntry -) -> None: - """Test that config flow only allows a single instance.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER} - ) - assert result["type"] == FlowResultType.ABORT - assert result["reason"] == "single_instance_allowed" +from tests.common import MockConfigEntry async def test_form(hass: HomeAssistant) -> None: """Test we get the form.""" + # Pretend we already set up a config entry. + hass.config.components.add("openai_conversation") + MockConfigEntry( + domain=DOMAIN, + state=config_entries.ConfigEntryState.LOADED, + ).add_to_hass(hass) + result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} )