Don't block motionEye setup on NoURLAvailableError (#54225)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Dermot Duffy 2021-08-07 21:29:52 -07:00 committed by GitHub
parent 11f15f66af
commit 75726a2695
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 28 deletions

View file

@ -32,11 +32,13 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.network import NoURLAvailableError
from homeassistant.setup import async_setup_component
from . import (
TEST_CAMERA,
TEST_CAMERA_DEVICE_IDENTIFIER,
TEST_CAMERA_ENTITY_ID,
TEST_CAMERA_ID,
TEST_CAMERA_NAME,
TEST_CAMERAS,
@ -251,6 +253,35 @@ async def test_setup_camera_with_correct_webhook(
assert not client.async_set_camera.called
async def test_setup_camera_with_no_home_assistant_urls(
hass: HomeAssistant,
caplog: Any,
) -> None:
"""Verify setup works without Home Assistant internal/external URLs."""
client = create_mock_motioneye_client()
config_entry = create_mock_motioneye_config_entry(hass, data={CONF_URL: TEST_URL})
with patch(
"homeassistant.components.motioneye.get_url", side_effect=NoURLAvailableError
):
await setup_mock_motioneye_config_entry(
hass,
config_entry=config_entry,
client=client,
)
# Should log a warning ...
assert "Unable to get Home Assistant URL" in caplog.text
# ... should not set callbacks in the camera ...
assert not client.async_set_camera.called
# ... but camera should still be present.
entity_state = hass.states.get(TEST_CAMERA_ENTITY_ID)
assert entity_state
async def test_good_query(hass: HomeAssistant, aiohttp_client: Any) -> None:
"""Test good callbacks."""
await async_setup_component(hass, "http", {"http": {}})