diff --git a/homeassistant/components/bring/config_flow.py b/homeassistant/components/bring/config_flow.py index 1f730abb432..756b2312e88 100644 --- a/homeassistant/components/bring/config_flow.py +++ b/homeassistant/components/bring/config_flow.py @@ -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( diff --git a/tests/components/bring/conftest.py b/tests/components/bring/conftest.py index eef333e07ca..0760bdd296a 100644 --- a/tests/components/bring/conftest.py +++ b/tests/components/bring/conftest.py @@ -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 diff --git a/tests/components/bring/test_config_flow.py b/tests/components/bring/test_config_flow.py index 351ba533101..86fdbc1853b 100644 --- a/tests/components/bring/test_config_flow.py +++ b/tests/components/bring/test_config_flow.py @@ -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