Do async_setup_platform in background (#36244)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
d488c779fc
commit
276f3afb00
161 changed files with 1184 additions and 305 deletions
|
@ -19,11 +19,12 @@ from tests.components.camera import common
|
|||
|
||||
|
||||
@pytest.fixture(name="mock_camera")
|
||||
def mock_camera_fixture(hass):
|
||||
async def mock_camera_fixture(hass):
|
||||
"""Initialize a demo camera platform."""
|
||||
assert hass.loop.run_until_complete(
|
||||
async_setup_component(hass, "camera", {camera.DOMAIN: {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, "camera", {camera.DOMAIN: {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.demo.camera.Path.read_bytes", return_value=b"Test",
|
||||
|
@ -51,6 +52,7 @@ async def image_mock_url_fixture(hass):
|
|||
await async_setup_component(
|
||||
hass, camera.DOMAIN, {camera.DOMAIN: {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_get_image_from_camera(hass, image_mock_url):
|
||||
|
@ -311,7 +313,10 @@ async def test_preload_stream(hass, mock_stream):
|
|||
"homeassistant.components.demo.camera.DemoCamera.stream_source",
|
||||
return_value="http://example.com",
|
||||
):
|
||||
await async_setup_component(hass, "camera", {DOMAIN: {"platform": "demo"}})
|
||||
assert await async_setup_component(
|
||||
hass, "camera", {DOMAIN: {"platform": "demo"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_request_stream.called
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue