Skip to content

Commit

Permalink
Add image test cases to generic (#69040)
Browse files Browse the repository at this point in the history
  • Loading branch information
davet2001 authored Apr 2, 2022
1 parent 1563420 commit c3354dc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Binary file added tests/components/generic/sample1_animate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions tests/components/generic/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test The generic (IP Camera) config flow."""

import errno
import os.path
from unittest.mock import patch

import av
Expand Down Expand Up @@ -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


@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
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."""
Expand Down

0 comments on commit c3354dc

Please sign in to comment.