mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Retry SmartThings setup when the subscription times out (#180495)
This commit is contained in:
@@ -199,7 +199,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmartThingsConfigEntry)
|
||||
entry.data[CONF_LOCATION_ID],
|
||||
entry.data[CONF_TOKEN][CONF_INSTALLED_APP_ID],
|
||||
)
|
||||
except SmartThingsSinkError as err:
|
||||
except (SmartThingsConnectionError, SmartThingsSinkError) as err:
|
||||
_LOGGER.exception("Couldn't create a new subscription")
|
||||
raise ConfigEntryNotReady from err
|
||||
subscription_id = subscription.subscription_id
|
||||
|
||||
@@ -188,16 +188,24 @@ async def test_create_subscription(
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_ac_rac_000001"])
|
||||
async def test_create_subscription_sink_error(
|
||||
@pytest.mark.parametrize(
|
||||
"error",
|
||||
[
|
||||
SmartThingsSinkError("Sink error"),
|
||||
SmartThingsConnectionError("Timeout occurred while connecting to SmartThings"),
|
||||
],
|
||||
)
|
||||
async def test_create_subscription_error(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
error: Exception,
|
||||
) -> None:
|
||||
"""Test handling an error when creating a subscription."""
|
||||
assert CONF_SUBSCRIPTION_ID not in mock_config_entry.data
|
||||
|
||||
devices.create_subscription.side_effect = SmartThingsSinkError("Sink error")
|
||||
devices.create_subscription.side_effect = error
|
||||
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user