1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Allow configuring username and password in generic camera config flow (#73804)

* Add ability to use user & pw not in stream url

* Increase test coverage to 100%

* Increase test coverage

* Verify that stream source includes user:pass

* Code review: refactor test to use MockConfigEntry

* Code review: Improve test docstring

* Edit comment; retrigger CI.

Co-authored-by: Dave T <davet2001@users.noreply.github.com>
This commit is contained in:
Dave T
2022-06-29 09:54:04 +01:00
committed by GitHub
parent fbaff21b67
commit e64336cb91
4 changed files with 59 additions and 14 deletions

View File

@@ -10,6 +10,7 @@ import respx
from homeassistant import config_entries, data_entry_flow
from homeassistant.components.camera import async_get_image
from homeassistant.components.generic.config_flow import slug
from homeassistant.components.generic.const import (
CONF_CONTENT_TYPE,
CONF_FRAMERATE,
@@ -517,6 +518,17 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
assert result5["errors"] == {"stream_source": "template_error"}
async def test_slug(hass, caplog):
"""
Test that the slug function generates an error in case of invalid template.
Other paths in the slug function are already tested by other tests.
"""
result = slug(hass, "http://127.0.0.2/testurl/{{1/0}}")
assert result is None
assert "Syntax error in" in caplog.text
@respx.mock
async def test_options_only_stream(hass, fakeimgbytes_png, mock_create_stream):
"""Test the options flow without a still_image_url."""