mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use friendly name for camera media source (#110882)
This commit is contained in:
@@ -8,6 +8,7 @@ from homeassistant.components import camera
|
||||
from homeassistant.components.camera.const import StreamType
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .common import WEBRTC_ANSWER
|
||||
@@ -70,3 +71,37 @@ async def mock_camera_web_rtc_fixture(hass):
|
||||
return_value=WEBRTC_ANSWER,
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_camera_with_device")
|
||||
async def mock_camera_with_device_fixture():
|
||||
"""Initialize a demo camera platform with a device."""
|
||||
dev_info = DeviceInfo(
|
||||
identifiers={("camera", "test_unique_id")},
|
||||
name="Test Camera Device",
|
||||
)
|
||||
|
||||
class UniqueIdMock(PropertyMock):
|
||||
def __get__(self, obj, obj_type=None):
|
||||
return obj.name
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.camera.Camera.has_entity_name",
|
||||
new_callable=PropertyMock(return_value=True),
|
||||
), patch(
|
||||
"homeassistant.components.camera.Camera.unique_id", new=UniqueIdMock()
|
||||
), patch(
|
||||
"homeassistant.components.camera.Camera.device_info",
|
||||
new_callable=PropertyMock(return_value=dev_info),
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_camera_with_no_name")
|
||||
async def mock_camera_with_no_name_fixture(mock_camera_with_device):
|
||||
"""Initialize a demo camera platform with a device and no name."""
|
||||
with patch(
|
||||
"homeassistant.components.camera.Camera._attr_name",
|
||||
new_callable=PropertyMock(return_value=None),
|
||||
):
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user