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

pull/110720/head
IceBotYT 2024-02-16 07:56:25 -05:00 committed by Franck Nijhof
parent 003673cd29
commit da61564f82
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
6 changed files with 52 additions and 74 deletions

View File

@ -6,11 +6,12 @@ import logging
from typing import Any
from linear_garage_door import Linear
from linear_garage_door.errors import InvalidLoginError, ResponseError
from linear_garage_door.errors import InvalidLoginError
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
@ -55,6 +56,7 @@ class LinearUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
email=self._email,
password=self._password,
device_id=self._device_id,
client_session=async_get_clientsession(self.hass),
)
except InvalidLoginError as err:
if (
@ -63,8 +65,6 @@ class LinearUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
):
raise ConfigEntryAuthFailed from err
raise ConfigEntryNotReady from err
except ResponseError as err:
raise ConfigEntryNotReady from err
if not self._devices:
self._devices = await linear.get_devices(self._site_id)

View File

@ -5,5 +5,5 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/linear_garage_door",
"iot_class": "cloud_polling",
"requirements": ["linear-garage-door==0.2.7"]
"requirements": ["linear-garage-door==0.2.9"]
}

View File

@ -1223,7 +1223,7 @@ lightwave==0.24
limitlessled==1.1.3
# homeassistant.components.linear_garage_door
linear-garage-door==0.2.7
linear-garage-door==0.2.9
# homeassistant.components.linode
linode-api==4.1.9b1

View File

@ -974,7 +974,7 @@ librouteros==3.2.0
libsoundtouch==0.8
# homeassistant.components.linear_garage_door
linear-garage-door==0.2.7
linear-garage-door==0.2.9
# homeassistant.components.lamarzocco
lmcloud==0.4.35

View File

@ -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:

View File

@ -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: