def test_browse_directory_uri(config, get_station_list_return_value_mock, station_list_result_mock): with mock.patch.object(APIClient, 'get_station_list', return_value=get_station_list_return_value_mock): backend = conftest.get_backend(config) results = backend.library.browse(backend.library.root_directory.uri) assert len(results) == 4 assert results[0].type == models.Ref.DIRECTORY assert results[0].uri == PandoraUri('genres').uri assert results[1].type == models.Ref.DIRECTORY assert results[1].name.startswith('QuickMix') assert results[1].uri == StationUri._from_station( Station.from_json(backend.api, station_list_result_mock['stations'][2])).uri assert results[2].type == models.Ref.DIRECTORY assert results[2].uri == StationUri._from_station( Station.from_json(backend.api, station_list_result_mock['stations'][1])).uri assert results[3].type == models.Ref.DIRECTORY assert results[3].uri == StationUri._from_station( Station.from_json(backend.api, station_list_result_mock['stations'][0])).uri
def test_station_uri_from_station(station_mock): station_uri = StationUri._from_station(station_mock) assert station_uri.uri == '{}:{}:{}:{}'.format( PandoraUri.SCHEME, station_uri.encode(conftest.MOCK_STATION_TYPE), station_uri.encode(conftest.MOCK_STATION_ID), station_uri.encode(conftest.MOCK_STATION_TOKEN))
def test_station_uri_from_station(get_station_mock_return_value): station_uri = StationUri._from_station(get_station_mock_return_value) assert station_uri.uri == '{}:{}:{}:{}'.format(PandoraUri.SCHEME, station_uri.encode(conftest.MOCK_STATION_TYPE), station_uri.encode(conftest.MOCK_STATION_ID), station_uri.encode(conftest.MOCK_STATION_TOKEN))
def test_station_uri_parse_returns_correct_type(): station_mock = mock.PropertyMock(spec=GenreStation) station_mock.id = 'G100' station_mock.token = 'G100' obj = StationUri._from_station(station_mock) assert type(obj) is GenreStationUri
def test_browse_station_uri(config, get_station_mock_return_value, get_station_playlist_mock): with mock.patch.object(MopidyAPIClient, 'get_station', return_value=get_station_mock_return_value): with mock.patch.object(Station, 'get_playlist', return_value=get_station_playlist_mock): backend = conftest.get_backend(config) station_uri = StationUri._from_station(get_station_mock_return_value) results = backend.library.browse(station_uri.uri) # Station should just contain the first track to be played. assert len(results) == 1
def test_station_uri_from_station(get_station_mock_return_value): station_uri = StationUri._from_station(get_station_mock_return_value) assert station_uri.uri == "{}:{}:{}:{}".format( PandoraUri.SCHEME, conftest.MOCK_STATION_TYPE, conftest.MOCK_STATION_ID, conftest.MOCK_STATION_TOKEN, )
def test_station_uri_parse(station_mock): station_uri = StationUri._from_station(station_mock) obj = PandoraUri._from_uri(station_uri.uri) assert type(obj) is StationUri assert obj.uri_type == conftest.MOCK_STATION_TYPE assert obj.station_id == conftest.MOCK_STATION_ID assert obj.token == conftest.MOCK_STATION_TOKEN assert obj.uri == station_uri.uri
def test_browse_station_uri(config, station_mock): with mock.patch.object(MopidyAPIClient, 'get_station', conftest.get_station_mock): with mock.patch.object(Station, 'get_playlist', conftest.get_station_playlist_mock): backend = conftest.get_backend(config) station_uri = StationUri._from_station(station_mock) results = backend.library.browse(station_uri.uri) # Station should just contain the first track to be played. assert len(results) == 1
def test_station_uri_parse(get_station_mock_return_value): station_uri = StationUri._from_station(get_station_mock_return_value) obj = PandoraUri._from_uri(station_uri.uri) assert type(obj) is StationUri assert obj.uri_type == conftest.MOCK_STATION_TYPE assert obj.station_id == conftest.MOCK_STATION_ID assert obj.token == conftest.MOCK_STATION_TOKEN assert obj.uri == station_uri.uri
def test_genre_station_uri_from_station_returns_correct_type(): genre_mock = mock.PropertyMock(spec=Station) genre_mock.id = 'id_mock' genre_mock.token = 'token_mock' obj = StationUri._from_station(genre_mock) assert type(obj) is StationUri assert obj.uri_type == 'station' assert obj.station_id == 'id_mock' assert obj.token == 'token_mock' assert obj.uri == 'pandora:station:id_mock:token_mock'
def test_genre_station_uri_from_station_returns_correct_type(): genre_mock = mock.PropertyMock(spec=Station) genre_mock.id = "id_mock" genre_mock.token = "token_mock" obj = StationUri._from_station(genre_mock) assert type(obj) is StationUri assert obj.uri_type == "station" assert obj.station_id == "id_mock" assert obj.token == "token_mock" assert obj.uri == "pandora:station:id_mock:token_mock"