mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Set username as entry title in Bring integration (#118974)
Set username as entry title
This commit is contained in:
parent
d40c940c20
commit
99b85e16d1
@ -53,7 +53,7 @@ class BringConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
bring = Bring(session, user_input[CONF_EMAIL], user_input[CONF_PASSWORD])
|
bring = Bring(session, user_input[CONF_EMAIL], user_input[CONF_PASSWORD])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await bring.login()
|
info = await bring.login()
|
||||||
await bring.load_lists()
|
await bring.load_lists()
|
||||||
except BringRequestException:
|
except BringRequestException:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
@ -66,7 +66,7 @@ class BringConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
await self.async_set_unique_id(bring.uuid)
|
await self.async_set_unique_id(bring.uuid)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=user_input[CONF_EMAIL], data=user_input
|
title=info["name"] or user_input[CONF_EMAIL], data=user_input
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -40,7 +40,7 @@ def mock_bring_client() -> Generator[AsyncMock]:
|
|||||||
):
|
):
|
||||||
client = mock_client.return_value
|
client = mock_client.return_value
|
||||||
client.uuid = UUID
|
client.uuid = UUID
|
||||||
client.login.return_value = True
|
client.login.return_value = {"name": "Bring"}
|
||||||
client.load_lists.return_value = {"lists": []}
|
client.load_lists.return_value = {"lists": []}
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ async def test_form(
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == MOCK_DATA_STEP["email"]
|
assert result["title"] == "Bring"
|
||||||
assert result["data"] == MOCK_DATA_STEP
|
assert result["data"] == MOCK_DATA_STEP
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ async def test_flow_user_init_data_unknown_error_and_recover(
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].title == MOCK_DATA_STEP["email"]
|
assert result["result"].title == "Bring"
|
||||||
|
|
||||||
assert result["data"] == MOCK_DATA_STEP
|
assert result["data"] == MOCK_DATA_STEP
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user