Continuous discovery of Sonos speakers (#23484)
This commit is contained in:
1 parent
5529bcc114
commit
0ecf152153
3 files changed
+47
-30
No files matched your search
@@ -35,8 +35,10 @@ def soco_fixture(music_library, speaker_info, dummy_soco_service):
|
||||
@pytest.fixture(name="discover")
|
||||
def discover_fixture(soco):
|
||||
"""Create a mock pysonos discover fixture."""
|
||||
with patch('pysonos.discover') as mock:
|
||||
mock.return_value = {soco}
|
||||
def do_callback(callback, **kwargs):
|
||||
callback(soco)
|
||||
|
||||
with patch('pysonos.discover_thread', side_effect=do_callback) as mock:
|
||||
yield mock
|
||||
|
||||
|
||||
|
||||
@@ -13,10 +13,14 @@ async def setup_platform(hass, config_entry, config):
|
||||
async def test_async_setup_entry_hosts(hass, config_entry, config, soco):
|
||||
"""Test static setup."""
|
||||
await setup_platform(hass, config_entry, config)
|
||||
assert hass.data[media_player.DATA_SONOS].entities[0].soco == soco
|
||||
|
||||
entity = hass.data[media_player.DATA_SONOS].entities[0]
|
||||
assert entity.soco == soco
|
||||
|
||||
|
||||
async def test_async_setup_entry_discover(hass, config_entry, discover):
|
||||
"""Test discovery setup."""
|
||||
await setup_platform(hass, config_entry, {})
|
||||
assert hass.data[media_player.DATA_SONOS].uids == {'RINCON_test'}
|
||||
|
||||
entity = hass.data[media_player.DATA_SONOS].entities[0]
|
||||
assert entity.unique_id == 'RINCON_test'
|
||||
Reference in new issue
Block a user