mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Use hostname as config entry title in SABnzbd (#131604)
This commit is contained in:
parent
60e1fb5d4f
commit
725d49ca9e
@ -6,6 +6,7 @@ import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
import yarl
|
||||
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_RECONFIGURE,
|
||||
@ -18,6 +19,7 @@ from homeassistant.helpers.selector import (
|
||||
TextSelectorConfig,
|
||||
TextSelectorType,
|
||||
)
|
||||
from homeassistant.util import slugify
|
||||
|
||||
from .const import DOMAIN
|
||||
from .helpers import get_client
|
||||
@ -67,8 +69,9 @@ class SABnzbdConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._get_reconfigure_entry(), data_updates=user_input
|
||||
)
|
||||
|
||||
parsed_url = yarl.URL(user_input[CONF_URL])
|
||||
return self.async_create_entry(
|
||||
title=user_input[CONF_API_KEY][:12], data=user_input
|
||||
title=slugify(parsed_url.host), data=user_input
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
|
@ -37,7 +37,7 @@ async def test_create_entry(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "edc3eee7330e"
|
||||
assert result["title"] == "localhost"
|
||||
assert result["data"] == {
|
||||
CONF_API_KEY: "edc3eee7330e4fdda04489e3fbc283d0",
|
||||
CONF_URL: "http://localhost:8080",
|
||||
@ -68,7 +68,7 @@ async def test_auth_error(hass: HomeAssistant, sabnzbd: AsyncMock) -> None:
|
||||
|
||||
assert "errors" not in result
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "edc3eee7330e"
|
||||
assert result["title"] == "localhost"
|
||||
assert result["data"] == {
|
||||
CONF_API_KEY: "edc3eee7330e4fdda04489e3fbc283d0",
|
||||
CONF_URL: "http://localhost:8080",
|
||||
|
Loading…
x
Reference in New Issue
Block a user