mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Use start_reauth helper method in broadlink and bthome (#124783)
* Use start_reauth helper method in broadlink reauth tests * Also include bthome
This commit is contained in:
parent
ef4caa951c
commit
26006f8036
@ -1054,7 +1054,12 @@ class MockConfigEntry(config_entries.ConfigEntry):
|
||||
"""
|
||||
self._async_set_state(hass, state, reason)
|
||||
|
||||
async def start_reauth_flow(self, hass: HomeAssistant) -> ConfigFlowResult:
|
||||
async def start_reauth_flow(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
context: dict[str, Any] | None = None,
|
||||
data: dict[str, Any] | None = None,
|
||||
) -> ConfigFlowResult:
|
||||
"""Start a reauthentication flow."""
|
||||
return await hass.config_entries.flow.async_init(
|
||||
self.domain,
|
||||
@ -1063,8 +1068,9 @@ class MockConfigEntry(config_entries.ConfigEntry):
|
||||
"entry_id": self.entry_id,
|
||||
"title_placeholders": {"name": self.title},
|
||||
"unique_id": self.unique_id,
|
||||
},
|
||||
data=self.data,
|
||||
}
|
||||
| (context or {}),
|
||||
data=self.data | (data or {}),
|
||||
)
|
||||
|
||||
|
||||
|
@ -734,13 +734,9 @@ async def test_flow_reauth_works(hass: HomeAssistant) -> None:
|
||||
mock_entry.add_to_hass(hass)
|
||||
mock_api = device.get_mock_api()
|
||||
mock_api.auth.side_effect = blke.AuthenticationError()
|
||||
data = {"name": device.name, **device.get_entry_data()}
|
||||
|
||||
with patch(DEVICE_FACTORY, return_value=mock_api):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||
)
|
||||
|
||||
result = await mock_entry.start_reauth_flow(hass, data={"name": device.name})
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reset"
|
||||
|
||||
@ -770,12 +766,8 @@ async def test_flow_reauth_invalid_host(hass: HomeAssistant) -> None:
|
||||
mock_entry.add_to_hass(hass)
|
||||
mock_api = device.get_mock_api()
|
||||
mock_api.auth.side_effect = blke.AuthenticationError()
|
||||
data = {"name": device.name, **device.get_entry_data()}
|
||||
|
||||
with patch(DEVICE_FACTORY, return_value=mock_api):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||
)
|
||||
result = await mock_entry.start_reauth_flow(hass, data={"name": device.name})
|
||||
|
||||
device.mac = get_device("Office").mac
|
||||
mock_api = device.get_mock_api()
|
||||
@ -804,12 +796,9 @@ async def test_flow_reauth_valid_host(hass: HomeAssistant) -> None:
|
||||
mock_entry.add_to_hass(hass)
|
||||
mock_api = device.get_mock_api()
|
||||
mock_api.auth.side_effect = blke.AuthenticationError()
|
||||
data = {"name": device.name, **device.get_entry_data()}
|
||||
|
||||
with patch(DEVICE_FACTORY, return_value=mock_api):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
|
||||
)
|
||||
result = await mock_entry.start_reauth_flow(hass, data={"name": device.name})
|
||||
|
||||
device.host = "192.168.1.128"
|
||||
mock_api = device.get_mock_api()
|
||||
|
@ -563,16 +563,7 @@ async def test_async_step_reauth_abort_early(hass: HomeAssistant) -> None:
|
||||
|
||||
device = DeviceData()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
"title_placeholders": {"name": entry.title},
|
||||
"unique_id": entry.unique_id,
|
||||
},
|
||||
data=entry.data | {"device": device},
|
||||
)
|
||||
result = await entry.start_reauth_flow(hass, data={"device": device})
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
Loading…
x
Reference in New Issue
Block a user