Add config entry for Sonos + Cast (#14955)
* Add config entry for Sonos * Lint * Use add_job * Add Cast config entry * Lint * Rename DOMAIN import * Mock pychromecast in test
This commit is contained in:
1 parent
c8e0de19b6
commit
2c6e6c2a6f
20 files changed
+432
-10
No files matched your search
@@ -0,0 +1 @@
|
||||
"""Tests for the Cast component."""
|
||||
@@ -0,0 +1,22 @@
|
||||
"""Tests for the Cast config flow."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import cast
|
||||
|
||||
from tests.common import MockDependency, mock_coro
|
||||
|
||||
|
||||
async def test_creating_entry_sets_up_media_player(hass):
|
||||
"""Test setting up Cast loads the media player."""
|
||||
with patch('homeassistant.components.media_player.cast.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup, \
|
||||
MockDependency('pychromecast', 'discovery'), \
|
||||
patch('pychromecast.discovery.discover_chromecasts',
|
||||
return_value=True):
|
||||
result = await hass.config_entries.flow.async_init(cast.DOMAIN)
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@@ -0,0 +1 @@
|
||||
"""Tests for the Sonos component."""
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Tests for the Sonos config flow."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import sonos
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
async def test_creating_entry_sets_up_media_player(hass):
|
||||
"""Test setting up Sonos loads the media player."""
|
||||
with patch('homeassistant.components.media_player.sonos.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup, \
|
||||
patch('soco.discover', return_value=True):
|
||||
result = await hass.config_entries.flow.async_init(sonos.DOMAIN)
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
Reference in new issue
Block a user