def test_create_music_service(): ms = MusicService("Spotify") assert ms.account.username == "12345678" with pytest.raises(MusicServiceException) as excinfo: unknown = MusicService("Unknown Music Service") assert "Unknown music service" in str(excinfo.value) with pytest.raises(MusicServiceException) as excinfo: soundcloud = MusicService("SoundCloud") assert "No account found" in str(excinfo.value)
def test_create_music_service(): ms = MusicService('Spotify') assert ms.account.username == '12345678' with pytest.raises(MusicServiceException) as excinfo: unknown = MusicService('Unknown Music Service') assert 'Unknown music service' in str(excinfo.value) with pytest.raises(MusicServiceException) as excinfo: soundcloud = MusicService('SoundCloud') assert 'No account found' in str(excinfo.value)
def test_sonos_uri_from_id(): spotify = MusicService('Spotify') track = 'spotify:track:2qs5ZcLByNTctJKbhAZ9JE' assert spotify.sonos_uri_from_id(track) == \ 'soco://spotify%3Atrack%3A2qs5ZcLByNTctJKbhAZ9JE?sid=9&sn=1' # Check for escaping with a few difficult characters track = 'spotify: track\2qc%ünicøde?' assert spotify.sonos_uri_from_id(track) == \ 'soco://spotify%3A%20track%02qc%25%C3%BCnic%C3%B8de%3F?sid=9&sn=1' # and a different service spreaker = MusicService('Spreaker') track = 'spreaker12345678' assert spreaker.sonos_uri_from_id(track) == \ 'soco://spreaker12345678?sid=163&sn=3'
def test_search(): spotify = MusicService("Spotify") # Set up dummy search categories spotify._get_search_prefix_map = lambda: { "stations": "search:station", "shows": "search:show", "hosts": "search:host", } categories = spotify.available_search_categories assert len(categories) == 3 assert set(categories) == {"stations", "shows", "hosts"} with pytest.raises(MusicServiceException) as excinfo: spotify.search("badcategory") assert "support the 'badcategory' search category" in str(excinfo.value)
def test_search(): spotify = MusicService('Spotify') # Set up dummy search categories spotify._get_search_prefix_map = lambda: { 'stations': 'search:station', 'shows': 'search:show', 'hosts': 'search:host', } categories = spotify.available_search_categories assert len(categories) == 3 assert set(categories) == {'stations', 'shows', 'hosts'} with pytest.raises(MusicServiceException) as excinfo: spotify.search('badcategory') assert "support the 'badcategory' search category" in str(excinfo.value)
def test_tunein(): """TuneIn is handles specially by MusicServices.""" tunein = MusicService("TuneIn") assert tunein assert tunein.service_id == "254" assert tunein.service_type == "65031" assert tunein.account.serial_number == "0"
def test_tunein(): """TuneIn is handles specially by MusicServices.""" tunein = MusicService('TuneIn') assert tunein assert tunein.service_id == '254' assert tunein.service_type == '65031' assert tunein.account.serial_number == '0'
def test_initialise_services(): assert MusicService._music_services_data is None data = MusicService._get_music_services_data() assert len(data) == 6 deezer = data['519'] assert deezer['Name'] == "Deezer" assert deezer['Capabilities'] == '563' assert deezer['Auth'] == 'UserId' assert deezer['Version'] == '1.1' assert deezer['ContainerType'] == 'MService' assert deezer['Id'] == '2' assert deezer['PresentationMapUri'] == 'http://sonos-pmap.ws.sonos.com/deezer_pmap.4.xml' assert deezer['ServiceType'] == '519'
def test_initialise_services(): assert MusicService._music_services_data is None data = MusicService._get_music_services_data() assert len(data) == 6 deezer = data['519'] assert deezer['Name'] == "Deezer" assert deezer['Capabilities'] == '563' assert deezer['Auth'] == 'UserId' assert deezer['Version'] == '1.1' assert deezer['ContainerType'] == 'MService' assert deezer['Id'] == '2' assert deezer['PresentationMapUri'] == \ 'http://sonos-pmap.ws.sonos.com/deezer_pmap.4.xml' assert deezer['ServiceType'] == '519'
def test_initialise_services(): assert MusicService._music_services_data is None data = MusicService._get_music_services_data() assert len(data) == 6 deezer = data["519"] assert deezer["Name"] == "Deezer" assert deezer["Capabilities"] == "563" assert deezer["Auth"] == "UserId" assert deezer["Version"] == "1.1" assert deezer["ContainerType"] == "MService" assert deezer["Id"] == "2" assert (deezer["PresentationMapUri"] == "http://sonos-pmap.ws.sonos.com/deezer_pmap.4.xml") assert deezer["ServiceType"] == "519"
def test_get_names(): names = MusicService.get_all_music_services_names() assert len(names) == 6 assert "Spotify" in names assert "Deezer" in names
def test_get_data_for_name(): s = MusicService.get_data_for_name("Spotify") assert s["Name"] == "Spotify" assert s["Capabilities"] == "2563"
def test_get_subscribed_names(): names = MusicService.get_subscribed_services_names() assert len(names) == 4 assert set(names) == {"TuneIn", "Spotify", "Spreaker", "radioPup"}
def test_get_subscribed_names(): names = MusicService.get_subscribed_services_names() assert len(names) == 4 assert set(names) == {'TuneIn', 'Spotify', 'Spreaker', 'radioPup'}
def test_get_data_for_name(): s = MusicService.get_data_for_name('Spotify') assert s['Name'] == "Spotify" assert s['Capabilities'] == '2563'
def test_desc(): spotify = MusicService("Spotify") assert spotify.desc == "SA_RINCON2311_12345678" spreaker = MusicService("Spreaker") assert spreaker.desc == "SA_RINCON41735_"
def test_tunein(): """TuneIn is handles specially by MusicServices""" tunein = MusicService('TuneIn') assert tunein
def test_desc(): spotify = MusicService('Spotify') assert spotify.desc == 'SA_RINCON2311_12345678' spreaker = MusicService('Spreaker') assert spreaker.desc == 'SA_RINCON41735_'