Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -10,18 +10,19 @@ 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.sonos.media_player.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup, \
|
||||
patch('pysonos.discover', return_value=True):
|
||||
with patch(
|
||||
"homeassistant.components.sonos.media_player.async_setup_entry",
|
||||
return_value=mock_coro(True),
|
||||
) as mock_setup, patch("pysonos.discover", return_value=True):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
sonos.DOMAIN, context={'source': config_entries.SOURCE_USER})
|
||||
sonos.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
# Confirmation form
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result['flow_id'], {})
|
||||
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -30,16 +31,14 @@ async def test_creating_entry_sets_up_media_player(hass):
|
||||
|
||||
async def test_configuring_sonos_creates_entry(hass):
|
||||
"""Test that specifying config will create an entry."""
|
||||
with patch('homeassistant.components.sonos.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup, \
|
||||
patch('pysonos.discover', return_value=True):
|
||||
await async_setup_component(hass, sonos.DOMAIN, {
|
||||
'sonos': {
|
||||
'media_player': {
|
||||
'interface_addr': '127.0.0.1',
|
||||
}
|
||||
}
|
||||
})
|
||||
with patch(
|
||||
"homeassistant.components.sonos.async_setup_entry", return_value=mock_coro(True)
|
||||
) as mock_setup, patch("pysonos.discover", return_value=True):
|
||||
await async_setup_component(
|
||||
hass,
|
||||
sonos.DOMAIN,
|
||||
{"sonos": {"media_player": {"interface_addr": "127.0.0.1"}}},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@@ -47,9 +46,9 @@ async def test_configuring_sonos_creates_entry(hass):
|
||||
|
||||
async def test_not_configuring_sonos_not_creates_entry(hass):
|
||||
"""Test that no config will not create an entry."""
|
||||
with patch('homeassistant.components.sonos.async_setup_entry',
|
||||
return_value=mock_coro(True)) as mock_setup, \
|
||||
patch('pysonos.discover', return_value=True):
|
||||
with patch(
|
||||
"homeassistant.components.sonos.async_setup_entry", return_value=mock_coro(True)
|
||||
) as mock_setup, patch("pysonos.discover", return_value=True):
|
||||
await async_setup_component(hass, sonos.DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
Reference in new issue
Block a user