Set username as entry title in Bring integration (#118974)

Set username as entry title
pull/118921/head
Mr. Bubbles 2024-06-06 20:03:58 +02:00 committed by GitHub
parent d40c940c20
commit 99b85e16d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View File

@ -53,7 +53,7 @@ class BringConfigFlow(ConfigFlow, domain=DOMAIN):
bring = Bring(session, user_input[CONF_EMAIL], user_input[CONF_PASSWORD])
try:
await bring.login()
info = await bring.login()
await bring.load_lists()
except BringRequestException:
errors["base"] = "cannot_connect"
@ -66,7 +66,7 @@ class BringConfigFlow(ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(bring.uuid)
self._abort_if_unique_id_configured()
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(

View File

@ -40,7 +40,7 @@ def mock_bring_client() -> Generator[AsyncMock]:
):
client = mock_client.return_value
client.uuid = UUID
client.login.return_value = True
client.login.return_value = {"name": "Bring"}
client.load_lists.return_value = {"lists": []}
yield client

View File

@ -45,7 +45,7 @@ async def test_form(
await hass.async_block_till_done()
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 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["result"].title == MOCK_DATA_STEP["email"]
assert result["result"].title == "Bring"
assert result["data"] == MOCK_DATA_STEP