示例#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_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'
示例#5
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"
示例#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_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)
示例#8
0
def test_desc():
    spotify = MusicService('Spotify')
    assert spotify.desc == 'SA_RINCON2311_12345678'
    spreaker = MusicService('Spreaker')
    assert spreaker.desc == 'SA_RINCON41735_'
示例#9
0
def test_tunein():
    """TuneIn is handles specially by MusicServices"""
    tunein = MusicService('TuneIn')
    assert tunein
示例#10
0
def test_desc():
    spotify = MusicService("Spotify")
    assert spotify.desc == "SA_RINCON2311_12345678"
    spreaker = MusicService("Spreaker")
    assert spreaker.desc == "SA_RINCON41735_"