mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 11:29:46 +00:00
Add go2rtc and extend camera integration for better WebRTC support (#124410)
This commit is contained in:
57
tests/components/go2rtc/conftest.py
Normal file
57
tests/components/go2rtc/conftest.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""Go2rtc test configuration."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
from go2rtc_client.client import _StreamClient, _WebRTCClient
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.go2rtc.const import CONF_BINARY, DOMAIN
|
||||
from homeassistant.const import CONF_HOST
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Override async_setup_entry."""
|
||||
with patch(
|
||||
"homeassistant.components.go2rtc.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
yield mock_setup_entry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_client() -> Generator[AsyncMock]:
|
||||
"""Mock a go2rtc client."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.go2rtc.Go2RtcClient",
|
||||
) as mock_client,
|
||||
patch(
|
||||
"homeassistant.components.go2rtc.config_flow.Go2RtcClient",
|
||||
new=mock_client,
|
||||
),
|
||||
):
|
||||
client = mock_client.return_value
|
||||
client.streams = Mock(spec_set=_StreamClient)
|
||||
client.webrtc = Mock(spec_set=_WebRTCClient)
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_server() -> Generator[Mock]:
|
||||
"""Mock a go2rtc server."""
|
||||
with patch("homeassistant.components.go2rtc.Server", autoSpec=True) as mock_server:
|
||||
yield mock_server
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry() -> MockConfigEntry:
|
||||
"""Mock a config entry."""
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
title=DOMAIN,
|
||||
data={CONF_HOST: "http://localhost:1984/", CONF_BINARY: "/usr/bin/go2rtc"},
|
||||
)
|
||||
Reference in New Issue
Block a user