Bump linear-garage-door to 0.2.9 (#110298)

This commit is contained in:
IceBotYT
2024-02-16 14:10:19 +01:00
committed by Franck Nijhof
parent 003673cd29
commit da61564f82
6 changed files with 52 additions and 74 deletions
@@ -65,54 +65,58 @@ async def test_form(hass: HomeAssistant) -> None:
async def test_reauth(hass: HomeAssistant) -> None:
"""Test reauthentication."""
entry = await async_init_integration(hass)
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,
)
assert result["type"] == FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
"homeassistant.components.linear_garage_door.config_flow.Linear.login",
"homeassistant.components.linear_garage_door.async_setup_entry",
return_value=True,
), patch(
"homeassistant.components.linear_garage_door.config_flow.Linear.get_sites",
return_value=[{"id": "test-site-id", "name": "test-site-name"}],
), patch(
"homeassistant.components.linear_garage_door.config_flow.Linear.close",
return_value=None,
), patch(
"uuid.uuid4",
return_value="test-uuid",
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"email": "new-email",
"password": "new-password",
entry = await async_init_integration(hass)
result1 = 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,
)
await hass.async_block_till_done()
assert result1["type"] == FlowResultType.FORM
assert result1["step_id"] == "user"
assert result2["type"] == FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
with patch(
"homeassistant.components.linear_garage_door.config_flow.Linear.login",
return_value=True,
), patch(
"homeassistant.components.linear_garage_door.config_flow.Linear.get_sites",
return_value=[{"id": "test-site-id", "name": "test-site-name"}],
), patch(
"homeassistant.components.linear_garage_door.config_flow.Linear.close",
return_value=None,
), patch(
"uuid.uuid4",
return_value="test-uuid",
):
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
{
"email": "new-email",
"password": "new-password",
},
)
await hass.async_block_till_done()
entries = hass.config_entries.async_entries()
assert len(entries) == 1
assert entries[0].data == {
"email": "new-email",
"password": "new-password",
"site_id": "test-site-id",
"device_id": "test-uuid",
}
assert result2["type"] == FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
entries = hass.config_entries.async_entries()
assert len(entries) == 1
assert entries[0].data == {
"email": "new-email",
"password": "new-password",
"site_id": "test-site-id",
"device_id": "test-uuid",
}
async def test_form_invalid_login(hass: HomeAssistant) -> None:
@@ -2,7 +2,7 @@
from unittest.mock import patch
from linear_garage_door.errors import InvalidLoginError, ResponseError
from linear_garage_door.errors import InvalidLoginError
from homeassistant.components.linear_garage_door.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
@@ -45,32 +45,6 @@ async def test_invalid_password(
assert flows[0]["context"]["source"] == "reauth"
async def test_response_error(hass: HomeAssistant) -> None:
"""Test response error."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={
"email": "test-email",
"password": "test-password",
"site_id": "test-site-id",
"device_id": "test-uuid",
},
)
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.linear_garage_door.coordinator.Linear.login",
side_effect=ResponseError,
):
assert not await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
entries = hass.config_entries.async_entries(DOMAIN)
assert entries
assert len(entries) == 1
assert entries[0].state == ConfigEntryState.SETUP_RETRY
async def test_invalid_login(
hass: HomeAssistant,
) -> None: