Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Commit

Permalink
Merge 020dfce into 7a65fc9
Browse files Browse the repository at this point in the history
  • Loading branch information
susansalkeld committed Sep 11, 2015
2 parents 7a65fc9 + 020dfce commit a623fb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions discogs_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ def search(self, *query, **fields):
function are serialized into the request's query string.
"""
if query:
fields['q'] = ' '.join(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),
Expand Down
7 changes: 7 additions & 0 deletions discogs_client/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def test_search(self):
self.assertTrue(isinstance(results[0], Artist))
self.assertTrue(isinstance(results[1], Release))

def test_utf8_search(self):
uni_string = 'caf\xe9'.encode('utf8')
try:
results = self.d.search(uni_string)
except Exception as e:
self.fail('exception {} was raised'.format(e))

def test_fee(self):
fee = self.d.fee_for(20.5, currency='EUR')
self.assertEqual(fee.currency, 'USD')
Expand Down

0 comments on commit a623fb9

Please sign in to comment.