mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Allow multiple config entries per host for transmission (#39127)
* Allow multiple integrations per host (check port) #36605 * Add test for allow multiple config entries per host for transmission
This commit is contained in:
parent
f295684c10
commit
62b1f23328
@ -56,7 +56,10 @@ class TransmissionFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if user_input is not None:
|
||||
|
||||
for entry in self.hass.config_entries.async_entries(DOMAIN):
|
||||
if entry.data[CONF_HOST] == user_input[CONF_HOST]:
|
||||
if (
|
||||
entry.data[CONF_HOST] == user_input[CONF_HOST]
|
||||
and entry.data[CONF_PORT] == user_input[CONF_PORT]
|
||||
):
|
||||
return self.async_abort(reason="already_configured")
|
||||
if entry.data[CONF_NAME] == user_input[CONF_NAME]:
|
||||
errors[CONF_NAME] = "name_exists"
|
||||
|
@ -204,13 +204,31 @@ async def test_host_already_configured(hass, api):
|
||||
options={CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
transmission.DOMAIN, context={"source": "user"}, data=MOCK_ENTRY
|
||||
)
|
||||
|
||||
mock_entry_unique_name = MOCK_ENTRY.copy()
|
||||
mock_entry_unique_name[CONF_NAME] = "Transmission 1"
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry_unique_name
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
mock_entry_unique_port = MOCK_ENTRY.copy()
|
||||
mock_entry_unique_port[CONF_PORT] = 9092
|
||||
mock_entry_unique_port[CONF_NAME] = "Transmission 2"
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry_unique_port
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
mock_entry_unique_host = MOCK_ENTRY.copy()
|
||||
mock_entry_unique_host[CONF_HOST] = "192.168.1.101"
|
||||
mock_entry_unique_host[CONF_NAME] = "Transmission 3"
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
transmission.DOMAIN, context={"source": "user"}, data=mock_entry_unique_host
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_name_already_configured(hass, api):
|
||||
"""Test name is already configured."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user