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

Generic IP Camera configflow 2 (#52360)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Dave T
2022-03-28 20:08:00 +01:00
committed by GitHub
parent de130d3b28
commit c1a2be72fc
14 changed files with 1296 additions and 190 deletions

View File

@@ -1,9 +1,14 @@
"""Test fixtures for the generic component."""
from io import BytesIO
from unittest.mock import Mock, patch
from PIL import Image
import pytest
import respx
from homeassistant import config_entries, setup
from homeassistant.components.generic.const import DOMAIN
@pytest.fixture(scope="package")
@@ -29,3 +34,34 @@ def fakeimgbytes_svg():
'<svg xmlns="http://www.w3.org/2000/svg"><circle r="50"/></svg>',
encoding="utf-8",
)
@pytest.fixture
def fakeimg_png(fakeimgbytes_png):
"""Set up respx to respond to test url with fake image bytes."""
respx.get("http://127.0.0.1/testurl/1").respond(stream=fakeimgbytes_png)
@pytest.fixture(scope="package")
def mock_av_open():
"""Fake container object with .streams.video[0] != None."""
fake = Mock()
fake.streams.video = ["fakevid"]
return patch(
"homeassistant.components.generic.config_flow.av.open",
return_value=fake,
)
@pytest.fixture
async def user_flow(hass):
"""Initiate a user flow."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors"] == {}
return result