Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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'
Пример #4
0
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)
Пример #5
0
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)
Пример #6
0
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)
Пример #7
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"
Пример #8
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'
Пример #9
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'
Пример #10
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'
Пример #11
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"
Пример #12
0
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'
Пример #13
0
def test_get_names():
    names = MusicService.get_all_music_services_names()
    assert len(names) == 6
    assert "Spotify" in names
    assert "Deezer" in names
Пример #14
0
def test_get_data_for_name():
    s = MusicService.get_data_for_name("Spotify")
    assert s["Name"] == "Spotify"
    assert s["Capabilities"] == "2563"
Пример #15
0
def test_get_subscribed_names():
    names = MusicService.get_subscribed_services_names()
    assert len(names) == 4
    assert set(names) == {"TuneIn", "Spotify", "Spreaker", "radioPup"}
Пример #16
0
def test_get_subscribed_names():
    names = MusicService.get_subscribed_services_names()
    assert len(names) == 4
    assert set(names) == {'TuneIn', 'Spotify', 'Spreaker', 'radioPup'}
Пример #17
0
def test_get_names():
    names = MusicService.get_all_music_services_names()
    assert len(names) == 6
    assert "Spotify" in names
    assert "Deezer" in names
Пример #18
0
def test_get_data_for_name():
    s = MusicService.get_data_for_name('Spotify')
    assert s['Name'] == "Spotify"
    assert s['Capabilities'] == '2563'
Пример #19
0
def test_desc():
    spotify = MusicService("Spotify")
    assert spotify.desc == "SA_RINCON2311_12345678"
    spreaker = MusicService("Spreaker")
    assert spreaker.desc == "SA_RINCON41735_"
Пример #20
0
def test_tunein():
    """TuneIn is handles specially by MusicServices"""
    tunein = MusicService('TuneIn')
    assert tunein
Пример #21
0
def test_get_data_for_name():
    s = MusicService.get_data_for_name('Spotify')
    assert s['Name'] == "Spotify"
    assert s['Capabilities'] == '2563'
Пример #22
0
def test_desc():
    spotify = MusicService('Spotify')
    assert spotify.desc == 'SA_RINCON2311_12345678'
    spreaker = MusicService('Spreaker')
    assert spreaker.desc == 'SA_RINCON41735_'
Пример #23
0
def test_get_subscribed_names():
    names = MusicService.get_subscribed_services_names()
    assert len(names) == 4
    assert set(names) == {'TuneIn', 'Spotify', 'Spreaker', 'radioPup'}