mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 04:08:19 -04:00
Use get_camera_from_entity_id in motioneye and shelly camera tests (#186594)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user