Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image test cases to generic #69040

Merged
merged 5 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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