Allow managing cloud webhook (#18672)
* Add cloud webhook support * Simplify payload * Add cloud http api tests * Fix tests * Lint * Handle cloud webhooks * Fix things * Fix name * Rename it to cloudhook * Final rename * Final final rename? * Fix docstring * More tests * Lint * Add types * Fix things
This commit is contained in:
1 parent
4a661e351f
commit
7848381f43
15 files changed
+611
-39
No files matched your search
@@ -0,0 +1,33 @@
|
||||
"""Test cloud API."""
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.cloud import cloud_api
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_check_token():
|
||||
"""Mock check token."""
|
||||
with patch('homeassistant.components.cloud.auth_api.'
|
||||
'check_token') as mock_check_token:
|
||||
yield mock_check_token
|
||||
|
||||
|
||||
async def test_create_cloudhook(hass, aioclient_mock):
|
||||
"""Test creating a cloudhook."""
|
||||
aioclient_mock.post('https://example.com/bla', json={
|
||||
'cloudhook_id': 'mock-webhook',
|
||||
'url': 'https://blabla'
|
||||
})
|
||||
cloud = Mock(
|
||||
hass=hass,
|
||||
id_token='mock-id-token',
|
||||
cloudhook_create_url='https://example.com/bla',
|
||||
)
|
||||
resp = await cloud_api.async_create_cloudhook(cloud)
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
assert await resp.json() == {
|
||||
'cloudhook_id': 'mock-webhook',
|
||||
'url': 'https://blabla'
|
||||
}
|
||||
Reference in new issue
Block a user