Make homekit camera snapshots HAP spec compliant (#35299)

This commit is contained in:
J. Nick Koston 2020-05-11 00:09:05 -05:00 committed by GitHub
parent 87e0f04515
commit 2e018ad841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 180 additions and 13 deletions

View file

@ -1,5 +1,7 @@
"""Collection of fixtures and functions for the HomeKit tests."""
from tests.async_mock import patch
from tests.async_mock import Mock, patch
EMPTY_8_6_JPEG = b"empty_8_6"
def patch_debounce():
@ -8,3 +10,16 @@ def patch_debounce():
"homeassistant.components.homekit.accessories.debounce",
lambda f: lambda *args, **kwargs: f(*args, **kwargs),
)
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
return mocked_turbo_jpeg