示例#1
0
def test_sets_types_parameter(
        web_client_mock, web_search_mock_large, provider, config,
        session_mock):
    web_client_mock.get.return_value = web_search_mock_large

    search.search(
        config['spotify'], session_mock, web_client_mock,
        {'any': ['ABBA']}, types=['album', 'artist'])

    web_client_mock.get.assert_called_once_with(
        'https://api.spotify.com/v1/search',
        params={
            'q': '"ABBA"',
            'limit': 50,
            'type': 'album,artist'})
示例#2
0
def test_sets_types_parameter(
        web_search_mock_large, provider, config, session_mock):
    responses.add(
        responses.GET, 'https://api.spotify.com/v1/search',
        body=json.dumps(web_search_mock_large))

    search.search(
        config['spotify'], session_mock, requests.Session(),
        {'any': ['ABBA']}, types=['album', 'artist'])

    assert len(responses.calls) == 1

    uri_parts = sorted(re.split('[?&]', responses.calls[0].request.url))
    assert (uri_parts == [
        'https://api.spotify.com/v1/search',
        'limit=50',
        'q=%22ABBA%22',
        'type=album%2Cartist'])
示例#3
0
def _get_search(
        config, session, web_client, query,
        album=False, artist=False, track=False):

    types = []
    if album:
        types.append('album')
    if artist:
        types.append('artist')
    if track:
        types.append('track')

    return search.search(
        config, session, web_client, query, types=types)
示例#4
0
 def search(self, query=None, uris=None, exact=False):
     return search.search(
         self._config, self._backend._session, self._requests_session,
         query, uris, exact)