Cast/Sonos: create config entry if manually configured (#15630)
* Cast/Sonos: create config entry if manually configured * Add test for helper
This commit is contained in:
parent
f3dfc433c2
commit
3204501174
6 changed files with 109 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import cast
|
||||
|
||||
from tests.common import MockDependency, mock_coro
|
||||
|
@ -20,3 +21,33 @@ async def test_creating_entry_sets_up_media_player(hass):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
|
||||
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('pychromecast.discovery.discover_chromecasts',
|
||||
return_value=True):
|
||||
await async_setup_component(hass, cast.DOMAIN, {
|
||||
'cast': {
|
||||
'some_config': 'to_trigger_import'
|
||||
}
|
||||
})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
|
||||
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('pychromecast.discovery.discover_chromecasts',
|
||||
return_value=True):
|
||||
await async_setup_component(hass, cast.DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue