2020-05-06 14:15:03 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from .payloads import SONOS_RESOURCES
|
|
|
|
|
|
|
|
|
|
|
|
def test_sonos_resources(mocked_account, requests_mock):
|
|
|
|
requests_mock.get("https://sonos.plex.tv/resources", text=SONOS_RESOURCES)
|
|
|
|
|
|
|
|
speakers = mocked_account.sonos_speakers()
|
|
|
|
assert len(speakers) == 3
|
|
|
|
|
2020-05-15 13:45:46 +00:00
|
|
|
# Finds individual speaker by name
|
2020-05-06 14:15:03 +00:00
|
|
|
speaker1 = mocked_account.sonos_speaker("Speaker 1")
|
2020-05-26 20:09:39 +00:00
|
|
|
assert speaker1.machineIdentifier == "RINCON_12345678901234561:1234567891"
|
2020-05-06 14:15:03 +00:00
|
|
|
|
2020-05-15 13:45:46 +00:00
|
|
|
# Finds speaker as part of group
|
|
|
|
speaker1 = mocked_account.sonos_speaker("Speaker 2")
|
2020-05-26 20:09:39 +00:00
|
|
|
assert speaker1.machineIdentifier == "RINCON_12345678901234562:1234567892"
|
2020-05-15 13:45:46 +00:00
|
|
|
|
2020-05-26 20:09:39 +00:00
|
|
|
# Finds speaker by Plex identifier
|
|
|
|
speaker3 = mocked_account.sonos_speaker_by_id("RINCON_12345678901234563:1234567893")
|
|
|
|
assert speaker3.title == "Speaker 3"
|
|
|
|
|
|
|
|
# Finds speaker by Sonos identifier
|
|
|
|
speaker3 = mocked_account.sonos_speaker_by_id("RINCON_12345678901234563")
|
2020-05-06 14:15:03 +00:00
|
|
|
assert speaker3.title == "Speaker 3"
|
2020-05-15 13:45:46 +00:00
|
|
|
|
|
|
|
assert mocked_account.sonos_speaker("Speaker X") is None
|
|
|
|
assert mocked_account.sonos_speaker_by_id("ID_DOES_NOT_EXIST") is None
|