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

Cherry pick single file from #134020 to fix generic component tests #134569

Merged
merged 1 commit into from
Jan 3, 2025
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
29 changes: 4 additions & 25 deletions tests/components/generic/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
CONF_RTSP_TRANSPORT,
CONF_USE_WALLCLOCK_AS_TIMESTAMPS,
)
from homeassistant.components.stream.worker import StreamWorkerError
from homeassistant.config_entries import ConfigEntryState, ConfigFlowResult
from homeassistant.const import (
CONF_AUTHENTICATION,
Expand Down Expand Up @@ -661,25 +660,6 @@ async def test_form_stream_other_error(hass: HomeAssistant, user_flow) -> None:
await hass.async_block_till_done()


@respx.mock
@pytest.mark.usefixtures("fakeimg_png")
async def test_form_stream_worker_error(
hass: HomeAssistant, user_flow: ConfigFlowResult
) -> None:
"""Test we handle a StreamWorkerError and pass the message through."""
with patch(
"homeassistant.components.generic.config_flow.create_stream",
side_effect=StreamWorkerError("Some message"),
):
result2 = await hass.config_entries.flow.async_configure(
user_flow["flow_id"],
TESTDATA,
)
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "unknown_with_details"}
assert result2["description_placeholders"] == {"error": "Some message"}


@respx.mock
async def test_form_stream_permission_error(
hass: HomeAssistant, fakeimgbytes_png: bytes, user_flow: ConfigFlowResult
Expand Down Expand Up @@ -949,23 +929,22 @@ async def test_options_still_and_stream_not_provided(

@respx.mock
@pytest.mark.usefixtures("fakeimg_png")
async def test_form_options_stream_worker_error(
async def test_form_options_permission_error(
hass: HomeAssistant, config_entry: MockConfigEntry
) -> None:
"""Test we handle a StreamWorkerError and pass the message through."""
"""Test we handle a PermissionError and pass the message through."""

result = await hass.config_entries.options.async_init(config_entry.entry_id)
with patch(
"homeassistant.components.generic.config_flow.create_stream",
side_effect=StreamWorkerError("Some message"),
side_effect=PermissionError("Some message"),
):
result2 = await hass.config_entries.options.async_configure(
result["flow_id"],
TESTDATA,
)
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "unknown_with_details"}
assert result2["description_placeholders"] == {"error": "Some message"}
assert result2["errors"] == {"stream_source": "stream_not_permitted"}


@pytest.mark.usefixtures("fakeimg_png")
Expand Down