hass-core/tests/components/generic/conftest.py
Dave T 89895c6c04
Improve tests for generic camera (#63197)
* Improve tests for generic camera

* Fix black error

* Code review: Move common code to fixtures

* Remove unnecessary patches from tests.

* Address review comments

* Code review: swap more patches for respx

* Code review: use _attr for frame interval.
2022-01-02 13:26:44 -08:00

31 lines
778 B
Python

"""Test fixtures for the generic component."""
from io import BytesIO
from PIL import Image
import pytest
@pytest.fixture(scope="package")
def fakeimgbytes_png():
"""Fake image in RAM for testing."""
buf = BytesIO()
Image.new("RGB", (1, 1)).save(buf, format="PNG")
yield bytes(buf.getbuffer())
@pytest.fixture(scope="package")
def fakeimgbytes_jpg():
"""Fake image in RAM for testing."""
buf = BytesIO() # fake image in ram for testing.
Image.new("RGB", (1, 1)).save(buf, format="jpeg")
yield bytes(buf.getbuffer())
@pytest.fixture(scope="package")
def fakeimgbytes_svg():
"""Fake image in RAM for testing."""
yield bytes(
'<svg xmlns="http://www.w3.org/2000/svg"><circle r="50"/></svg>',
encoding="utf-8",
)