Skip to content

Commit 3dea0a9

Browse files
authored
Use error introduced in home-assistant#154579 in august integration (home-assistant#156096)
1 parent a94c333 commit 3dea0a9

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

homeassistant/components/august/__init__.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
1515
from homeassistant.core import HomeAssistant
1616
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
17-
from homeassistant.helpers import (
18-
config_entry_oauth2_flow,
19-
device_registry as dr,
20-
issue_registry as ir,
17+
from homeassistant.helpers import device_registry as dr, issue_registry as ir
18+
from homeassistant.helpers.config_entry_oauth2_flow import (
19+
ImplementationUnavailableError,
20+
OAuth2Session,
21+
async_get_config_entry_implementation,
2122
)
2223

2324
from .const import DEFAULT_AUGUST_BRAND, DOMAIN, PLATFORMS
@@ -37,14 +38,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: AugustConfigEntry) -> bo
3738

3839
session = async_create_august_clientsession(hass)
3940
try:
40-
implementation = (
41-
await config_entry_oauth2_flow.async_get_config_entry_implementation(
42-
hass, entry
43-
)
44-
)
45-
except ValueError as err:
41+
implementation = await async_get_config_entry_implementation(hass, entry)
42+
except ImplementationUnavailableError as err:
4643
raise ConfigEntryNotReady("OAuth implementation not available") from err
47-
oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
44+
oauth_session = OAuth2Session(hass, entry, implementation)
4845
august_gateway = AugustGateway(Path(hass.config.config_dir), session, oauth_session)
4946
try:
5047
await async_setup_august(hass, entry, august_gateway)

tests/components/august/mocks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ def patch_august_setup():
121121
with (
122122
patch("yalexs.manager.gateway.ApiAsync") as api_mock,
123123
patch.object(_RateLimitChecker, "register_wakeup") as authenticate_mock,
124-
patch(
125-
"homeassistant.components.august.config_entry_oauth2_flow.async_get_config_entry_implementation"
126-
),
124+
patch("homeassistant.components.august.async_get_config_entry_implementation"),
127125
):
128126
yield api_mock, authenticate_mock
129127

tests/components/august/test_init.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
entity_registry as er,
2525
issue_registry as ir,
2626
)
27+
from homeassistant.helpers.config_entry_oauth2_flow import (
28+
ImplementationUnavailableError,
29+
)
2730
from homeassistant.setup import async_setup_component
2831

2932
from .mocks import (
@@ -294,8 +297,8 @@ async def test_oauth_implementation_not_available(hass: HomeAssistant) -> None:
294297
entry = await mock_august_config_entry(hass)
295298

296299
with patch(
297-
"homeassistant.components.august.config_entry_oauth2_flow.async_get_config_entry_implementation",
298-
side_effect=ValueError("Implementation not available"),
300+
"homeassistant.components.august.async_get_config_entry_implementation",
301+
side_effect=ImplementationUnavailableError,
299302
):
300303
await hass.config_entries.async_setup(entry.entry_id)
301304
await hass.async_block_till_done()

0 commit comments

Comments
 (0)