mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Add streaming support w/ audio to Android IP Webcam integration (#126009)
* Add streaming support w/ audio to Android IP Webcam integration * ruff reformat * Fix ruff * Break long comments and strings * Add camera test * Fix docstring * Remove dead code * Call library function to get URL * Simplify --------- Co-authored-by: Shay Levy <levyshay1@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
54
tests/components/android_ip_webcam/test_camera.py
Normal file
54
tests/components/android_ip_webcam/test_camera.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""Test the Android IP Webcam camera."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.android_ip_webcam.const import DOMAIN
|
||||
from homeassistant.components.camera import async_get_stream_source
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("aioclient_mock_fixture")
|
||||
@pytest.mark.parametrize(
|
||||
("config", "expected_stream_source"),
|
||||
[
|
||||
(
|
||||
{
|
||||
"host": "1.1.1.1",
|
||||
"port": 8080,
|
||||
"username": "user",
|
||||
"password": "pass",
|
||||
},
|
||||
"rtsp://user:pass@1.1.1.1:8080/h264_aac.sdp",
|
||||
),
|
||||
(
|
||||
{
|
||||
"host": "1.1.1.1",
|
||||
"port": 8080,
|
||||
},
|
||||
"rtsp://1.1.1.1:8080/h264_aac.sdp",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_camera_stream_source(
|
||||
hass: HomeAssistant,
|
||||
config: dict[str, Any],
|
||||
expected_stream_source: str,
|
||||
) -> None:
|
||||
"""Test camera stream source."""
|
||||
entity_id = "camera.1_1_1_1"
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=config)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
|
||||
stream_source = await async_get_stream_source(hass, entity_id)
|
||||
|
||||
assert stream_source == expected_stream_source
|
Reference in New Issue
Block a user