Implement resilient startup for bond integration with ConfigEntryNotReady support (#38253)

This commit is contained in:
Eugene Prystupa authored and GitHub committed 2020-07-26 18:27:18 -05:00
1 parent 455ac1cadf
commit 4d73f107c4
3 files changed
+32 -4

No files matched your search

+16
View File
@@ -1,8 +1,13 @@
"""Tests for the Bond module."""
from aiohttp import ClientConnectionError
import pytest
from homeassistant.components.bond import async_setup_entry
from homeassistant.components.bond.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
from homeassistant.setup import async_setup_component
@@ -18,6 +23,17 @@ async def test_async_setup_no_domain_config(hass: HomeAssistant):
assert result is True
async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant):
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
)
with patch_bond_version(side_effect=ClientConnectionError()):
with pytest.raises(ConfigEntryNotReady):
await async_setup_entry(hass, config_entry)
async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAssistant):
"""Test that configuring entry sets up cover domain."""
config_entry = MockConfigEntry(