From 7fc59e815db53106b224a2e9563ef9580c5189ea Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 15 Oct 2026 08:55:53 +0200 Subject: [PATCH] Use get_camera_from_entity_id in motioneye and shelly camera tests (#186594) --- tests/components/motioneye/test_camera.py | 6 +++--- tests/components/shelly/test_camera.py | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/components/motioneye/test_camera.py b/tests/components/motioneye/test_camera.py index 5e6f808dd85a..ab560c591f55 100644 --- a/tests/components/motioneye/test_camera.py +++ b/tests/components/motioneye/test_camera.py @@ -29,9 +29,9 @@ import probatio import pytest from homeassistant.components.camera import ( - DATA_COMPONENT, async_get_image, async_get_mjpeg_stream, + get_camera_from_entity_id, ) from homeassistant.components.motioneye import get_motioneye_device_identifier from homeassistant.components.motioneye.const import ( @@ -265,8 +265,8 @@ async def test_get_still_image_without_camera(hass: HomeAssistant) -> None: await setup_mock_motioneye_config_entry(hass, client=client) await hass.async_block_till_done() - camera = hass.data[DATA_COMPONENT].get_entity(TEST_CAMERA_ENTITY_ID) - assert camera is not None + camera = get_camera_from_entity_id(hass, TEST_CAMERA_ENTITY_ID) + # Dropping the camera from the coordinator data would remove the device and entity camera._camera = None assert await camera.async_camera_image() is None diff --git a/tests/components/shelly/test_camera.py b/tests/components/shelly/test_camera.py index bfd839f0e149..c3a7de9dc174 100644 --- a/tests/components/shelly/test_camera.py +++ b/tests/components/shelly/test_camera.py @@ -15,7 +15,6 @@ import pytest from syrupy.assertion import SnapshotAssertion from homeassistant.components.camera import ( - DATA_COMPONENT, DOMAIN as CAMERA_DOMAIN, CameraState, get_camera_from_entity_id, @@ -255,9 +254,8 @@ async def test_camera_off_when_streamer_stopped( await init_integration(hass, 3, model=MODEL_CAMERA) - camera = hass.data[DATA_COMPONENT].get_entity(CAMERA_ENTITY_ID) - assert camera is not None - assert camera.is_on is False + with pytest.raises(HomeAssistantError, match="Camera is off"): + get_camera_from_entity_id(hass, CAMERA_ENTITY_ID) async def test_camera_properties_when_device_not_initialized(