File tree Expand file tree Collapse file tree 4 files changed +29
-1
lines changed
homeassistant/components/portainer
tests/components/portainer Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,8 @@ async def async_step_reconfigure(
159159 _LOGGER .exception ("Unexpected exception" )
160160 errors ["base" ] = "unknown"
161161 else :
162+ await self .async_set_unique_id (user_input [CONF_API_TOKEN ])
163+ self ._abort_if_unique_id_configured ()
162164 return self .async_update_reload_and_abort (
163165 reconf_entry ,
164166 data_updates = {
Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ def mock_config_entry() -> MockConfigEntry:
7373 domain = DOMAIN ,
7474 title = "Portainer test" ,
7575 data = MOCK_TEST_CONFIG ,
76+ unique_id = MOCK_TEST_CONFIG [CONF_API_TOKEN ],
7677 entry_id = "portainer_test_entry_123" ,
7778 version = 2 ,
7879 )
Original file line number Diff line number Diff line change 2121 'subentries': list([
2222 ]),
2323 'title': 'Portainer test',
24- 'unique_id': None ,
24+ 'unique_id': 'test_api_token' ,
2525 'version': 2,
2626 }),
2727 'coordinator': dict({
Original file line number Diff line number Diff line change @@ -255,6 +255,31 @@ async def test_full_flow_reconfigure(
255255 assert len (mock_setup_entry .mock_calls ) == 1
256256
257257
258+ async def test_full_flow_reconfigure_unique_id (
259+ hass : HomeAssistant ,
260+ mock_portainer_client : AsyncMock ,
261+ mock_setup_entry : MagicMock ,
262+ mock_config_entry : MockConfigEntry ,
263+ ) -> None :
264+ """Test the full flow of the config flow, this time with a known unique ID."""
265+ mock_config_entry .add_to_hass (hass )
266+ result = await mock_config_entry .start_reconfigure_flow (hass )
267+ assert result ["type" ] is FlowResultType .FORM
268+ assert result ["step_id" ] == "reconfigure"
269+
270+ result = await hass .config_entries .flow .async_configure (
271+ result ["flow_id" ],
272+ user_input = MOCK_USER_SETUP ,
273+ )
274+
275+ assert result ["type" ] is FlowResultType .ABORT
276+ assert result ["reason" ] == "already_configured"
277+ assert mock_config_entry .data [CONF_API_TOKEN ] == "test_api_token"
278+ assert mock_config_entry .data [CONF_URL ] == "https://127.0.0.1:9000/"
279+ assert mock_config_entry .data [CONF_VERIFY_SSL ] is True
280+ assert len (mock_setup_entry .mock_calls ) == 0
281+
282+
258283@pytest .mark .parametrize (
259284 ("exception" , "reason" ),
260285 [
You can’t perform that action at this time.
0 commit comments