Files
homeassistant-core/tests/components/camera/common.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
728 B
Python
Raw Normal View History

2018-09-26 09:49:55 +02:00
"""Collection of helper methods.
All containing methods are legacy helpers that should not be used by new
components. Instead call the service directly.
"""
from unittest.mock import Mock
EMPTY_8_6_JPEG = b"empty_8_6"
2022-02-08 14:32:02 -08:00
WEBRTC_ANSWER = "a=sendonly"
2018-09-26 09:49:55 +02:00
def mock_turbo_jpeg(
first_width=None, second_width=None, first_height=None, second_height=None
):
"""Mock a TurboJPEG instance."""
mocked_turbo_jpeg = Mock()
mocked_turbo_jpeg.decode_header.side_effect = [
(first_width, first_height, 0, 0),
(second_width, second_height, 0, 0),
]
mocked_turbo_jpeg.scale_with_quality.return_value = EMPTY_8_6_JPEG
2021-12-23 00:24:53 +08:00
mocked_turbo_jpeg.encode.return_value = EMPTY_8_6_JPEG
return mocked_turbo_jpeg