Add image test cases to generic (#69040)

This commit is contained in:
Dave T 2022-04-02 09:54:19 +01:00 committed by GitHub
parent 1563420de8
commit c3354dcaae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -1,6 +1,7 @@
"""Test The generic (IP Camera) config flow.""" """Test The generic (IP Camera) config flow."""
import errno import errno
import os.path
from unittest.mock import patch from unittest.mock import patch
import av import av
@ -137,6 +138,30 @@ async def test_form_only_svg_whitespace(hass, fakeimgbytes_svg, user_flow):
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@respx.mock
@pytest.mark.parametrize(
"image_file",
[
("sample1_animate.png"),
("sample2_jpeg_odd_header.jpg"),
("sample3_jpeg_odd_header.jpg"),
("sample4_K5-60mileAnim-320x240.gif"),
],
)
async def test_form_only_still_sample(hass, user_flow, image_file):
"""Test various sample images #69037."""
image_path = os.path.join(os.path.dirname(__file__), image_file)
with open(image_path, "rb") as image:
respx.get("http://127.0.0.1/testurl/1").respond(stream=image.read())
data = TESTDATA.copy()
data.pop(CONF_STREAM_SOURCE)
result2 = await hass.config_entries.flow.async_configure(
user_flow["flow_id"],
data,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@respx.mock @respx.mock
async def test_form_rtsp_mode(hass, fakeimg_png, mock_av_open, user_flow): async def test_form_rtsp_mode(hass, fakeimg_png, mock_av_open, user_flow):
"""Test we complete ok if the user enters a stream url.""" """Test we complete ok if the user enters a stream url."""