Beispiel #1
0
def test_update_qs():
    assert update_qs('http://example.com',
                     {'foo': 'bar'}) == 'http://example.com?foo=bar'
    assert update_qs('http://example.com?foo=bar',
                     {'foo': 'baz'}) == 'http://example.com?foo=bar&foo=baz'

    # be careful for dict iteration order is not deterministic
    result = update_qs('http://example.com?c=3&a=yep', {'a': 1, 'b': '1'})
    try:
        assert result == 'http://example.com?c=3&a=yep&a=1&b=1'
    except AssertionError:
        assert result == 'http://example.com?c=3&a=yep&b=1&a=1'

    assert update_qs('http://example.com',
                     {'a': 't\xe9st'}) == 'http://example.com?a=t%C3%A9st'
Beispiel #2
0
 def search(self, *query, **fields):
     """
     Search the Discogs database. Returns a paginated list of objects
     (Artists, Releases, Masters, and Labels). The keyword arguments to this
     function are serialized into the request's query string.
     """
     if query:
         fields['q'] = ' '.join(query)
     return models.MixedPaginatedList(
         self, update_qs(self._base_url + '/database/search', fields),
         'results')
Beispiel #3
0
    def search(self, *query, **fields):
        """
        Search the Discogs database. Returns a paginated list of objects
        (Artists, Releases, Masters, and Labels). The keyword arguments to this
        function are serialized into the request's query string.
        """
        if query:
            fields['q'] = ' '.join(query)

        return models.MixedPaginatedList(
            self,
            update_qs(self._base_url + '/database/search', fields),
            'results'
        )
Beispiel #4
0
    def _url_for_page(self, page):
        base_qs = {
            'page': page,
            'per_page': self._per_page,
        }

        if self._sort_key is not None:
            base_qs.update({
                'sort': self._sort_key,
                'sort_order': self._sort_order,
            })

        base_qs.update(self._filters)

        return update_qs(self.url, base_qs)
Beispiel #5
0
 def search(self, *query, **fields):
     """
     Search the Discogs database. Returns a paginated list of objects
     (Artists, Releases, Masters, and Labels). The keyword arguments to this
     function are serialized into the request's query string.
     """
     if query:
         unicode_query = []
         for q in query:
             try:
                 unicode_q = q.decode('utf8')
             except (UnicodeDecodeError, UnicodeEncodeError,
                     AttributeError):
                 unicode_q = q
             unicode_query.append(unicode_q)
         fields['q'] = ' '.join(unicode_query)
     return models.MixedPaginatedList(
         self, update_qs(self._base_url + '/database/search', fields),
         'results')
 def search(self, *query, **fields):
     """
     Search the Discogs database. Returns a paginated list of objects
     (Artists, Releases, Masters, and Labels). The keyword arguments to this
     function are serialized into the request's query string.
     """
     if query:
         unicode_query = []
         for q in query:
             try:
                 unicode_q = q.decode('utf8')
             except (UnicodeDecodeError, UnicodeEncodeError, AttributeError):
                 unicode_q = q
             unicode_query.append(unicode_q)
         fields['q'] = ' '.join(unicode_query)
     return models.MixedPaginatedList(
         self,
         update_qs(self._base_url + '/database/search', fields),
         'results'
     )