mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix camera tests (#57020)
This commit is contained in:
parent
3976443292
commit
1747578be5
@ -71,6 +71,17 @@ async def fake_post_request(*args, **kwargs):
|
||||
)
|
||||
|
||||
|
||||
async def fake_get_image(*args, **kwargs):
|
||||
"""Return fake data."""
|
||||
if "url" not in kwargs:
|
||||
return "{}"
|
||||
|
||||
endpoint = kwargs["url"].split("/")[-1]
|
||||
|
||||
if endpoint in "snapshot_720.jpg":
|
||||
return b"test stream image bytes"
|
||||
|
||||
|
||||
async def fake_post_request_no_data(*args, **kwargs):
|
||||
"""Fake error during requesting backend data."""
|
||||
return "{}"
|
||||
|
@ -4,7 +4,7 @@ from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from .common import ALL_SCOPES, fake_post_request
|
||||
from .common import ALL_SCOPES, fake_get_image, fake_post_request
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@ -60,6 +60,7 @@ def netatmo_auth():
|
||||
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth"
|
||||
) as mock_auth:
|
||||
mock_auth.return_value.async_post_request.side_effect = fake_post_request
|
||||
mock_auth.return_value.async_get_image.side_effect = fake_get_image
|
||||
mock_auth.return_value.async_addwebhook.side_effect = AsyncMock()
|
||||
mock_auth.return_value.async_dropwebhook.side_effect = AsyncMock()
|
||||
yield
|
||||
|
@ -478,6 +478,7 @@ async def test_camera_image_raises_exception(hass, config_entry, requests_mock):
|
||||
"homeassistant.components.webhook.async_generate_url"
|
||||
):
|
||||
mock_auth.return_value.async_post_request.side_effect = fake_post
|
||||
mock_auth.return_value.async_get_image.side_effect = fake_post
|
||||
mock_auth.return_value.async_addwebhook.side_effect = AsyncMock()
|
||||
mock_auth.return_value.async_dropwebhook.side_effect = AsyncMock()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user