Use a future for mock coro (#34989)
This commit is contained in:
1 parent
ba7391528f
commit
76f392476b
26 files changed
+154
-262
No files matched your search
@@ -1,19 +1,18 @@
|
||||
"""Tests for the Cast config flow."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components import cast
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockDependency, mock_coro
|
||||
from tests.async_mock import patch
|
||||
|
||||
|
||||
async def test_creating_entry_sets_up_media_player(hass):
|
||||
"""Test setting up Cast loads the media player."""
|
||||
with patch(
|
||||
"homeassistant.components.cast.media_player.async_setup_entry",
|
||||
return_value=mock_coro(True),
|
||||
) as mock_setup, MockDependency("pychromecast", "discovery"), patch(
|
||||
return_value=True,
|
||||
) as mock_setup, patch(
|
||||
"pychromecast.discovery.discover_chromecasts", return_value=True
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -34,8 +33,8 @@ async def test_creating_entry_sets_up_media_player(hass):
|
||||
async def test_configuring_cast_creates_entry(hass):
|
||||
"""Test that specifying config will create an entry."""
|
||||
with patch(
|
||||
"homeassistant.components.cast.async_setup_entry", return_value=mock_coro(True)
|
||||
) as mock_setup, MockDependency("pychromecast", "discovery"), patch(
|
||||
"homeassistant.components.cast.async_setup_entry", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"pychromecast.discovery.discover_chromecasts", return_value=True
|
||||
):
|
||||
await async_setup_component(
|
||||
@@ -49,8 +48,8 @@ async def test_configuring_cast_creates_entry(hass):
|
||||
async def test_not_configuring_cast_not_creates_entry(hass):
|
||||
"""Test that no config will not create an entry."""
|
||||
with patch(
|
||||
"homeassistant.components.cast.async_setup_entry", return_value=mock_coro(True)
|
||||
) as mock_setup, MockDependency("pychromecast", "discovery"), patch(
|
||||
"homeassistant.components.cast.async_setup_entry", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"pychromecast.discovery.discover_chromecasts", return_value=True
|
||||
):
|
||||
await async_setup_component(hass, cast.DOMAIN, {})
|
||||
|
||||
Reference in new issue
Block a user