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

Improve generic camera preview tests #127382

Merged
merged 1 commit into from
Oct 3, 2024
Merged
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
10 changes: 5 additions & 5 deletions tests/components/generic/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ async def test_form(
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "user_confirm_still"
client = await hass_client()
preview_id = result1["flow_id"]
preview_url = result1["description_placeholders"]["preview_url"]
# Check the preview image works.
resp = await client.get(f"/api/generic/preview_flow_image/{preview_id}?t=1")
resp = await client.get(preview_url)
assert resp.status == HTTPStatus.OK
assert await resp.read() == fakeimgbytes_png
result2 = await hass.config_entries.flow.async_configure(
Expand All @@ -118,7 +118,7 @@ async def test_form(

await hass.async_block_till_done()
# Check that the preview image is disabled after.
resp = await client.get(f"/api/generic/preview_flow_image/{preview_id}")
resp = await client.get(preview_url)
assert resp.status == HTTPStatus.NOT_FOUND
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1
Expand Down Expand Up @@ -212,10 +212,10 @@ async def test_form_still_preview_cam_off(
)
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "user_confirm_still"
preview_id = result1["flow_id"]
preview_url = result1["description_placeholders"]["preview_url"]
# Try to view the image, should be unavailable.
client = await hass_client()
resp = await client.get(f"/api/generic/preview_flow_image/{preview_id}?t=1")
resp = await client.get(preview_url)
assert resp.status == HTTPStatus.SERVICE_UNAVAILABLE


Expand Down