mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix validate webhook requirements (#22248)
This commit is contained in:
parent
f64a99878f
commit
6526c68e2d
@ -65,6 +65,8 @@ def validate_webhook_requirements(hass: HomeAssistantType) -> bool:
|
||||
"""Ensure HASS is setup properly to receive webhooks."""
|
||||
if cloud.async_active_subscription(hass):
|
||||
return True
|
||||
if hass.data[DOMAIN][CONF_CLOUDHOOK_URL] is not None:
|
||||
return True
|
||||
return get_webhook_url(hass).lower().startswith('https://')
|
||||
|
||||
|
||||
|
@ -189,6 +189,33 @@ async def test_config_entry_loads_platforms(
|
||||
assert forward_mock.call_count == len(SUPPORTED_PLATFORMS)
|
||||
|
||||
|
||||
async def test_config_entry_loads_unconnected_cloud(
|
||||
hass, config_entry, app, installed_app,
|
||||
device, smartthings_mock, subscription_factory, scene):
|
||||
"""Test entry loads during startup when cloud isn't connected."""
|
||||
setattr(hass.config_entries, '_entries', [config_entry])
|
||||
hass.data[DOMAIN][CONF_CLOUDHOOK_URL] = "https://test.cloud"
|
||||
hass.config.api.base_url = 'http://0.0.0.0'
|
||||
api = smartthings_mock.return_value
|
||||
api.app.return_value = mock_coro(return_value=app)
|
||||
api.installed_app.return_value = mock_coro(return_value=installed_app)
|
||||
api.devices.side_effect = \
|
||||
lambda *args, **kwargs: mock_coro(return_value=[device])
|
||||
api.scenes.return_value = mock_coro(return_value=[scene])
|
||||
mock_token = Mock()
|
||||
mock_token.access_token.return_value = str(uuid4())
|
||||
mock_token.refresh_token.return_value = str(uuid4())
|
||||
api.generate_tokens.return_value = mock_coro(return_value=mock_token)
|
||||
subscriptions = [subscription_factory(capability)
|
||||
for capability in device.capabilities]
|
||||
api.subscriptions.return_value = mock_coro(return_value=subscriptions)
|
||||
with patch.object(hass.config_entries, 'async_forward_entry_setup',
|
||||
return_value=mock_coro()) as forward_mock:
|
||||
assert await smartthings.async_setup_entry(hass, config_entry)
|
||||
await hass.async_block_till_done()
|
||||
assert forward_mock.call_count == len(SUPPORTED_PLATFORMS)
|
||||
|
||||
|
||||
async def test_unload_entry(hass, config_entry):
|
||||
"""Test entries are unloaded correctly."""
|
||||
connect_disconnect = Mock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user