mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-10-10 17:00:46 +00:00
Add support to search multiple markets at once (#526)
* Add support to search multiple markets. Pass in a list or ALL to search all markets. * pep8 formatting and verification with flake8 * work on comments from stephanebruckert * pep8 formatting * run autopep8 formatting * fix typo * allow tuple of markets to be passed. Add unit tests for this case
This commit is contained in:
1 parent
a8b77ac37d
commit
2bfa7e0151
4 files changed
+150
-7
No files matched your search
@@ -175,6 +175,40 @@ class AuthTestSpotipy(unittest.TestCase):
|
||||
self.assertTrue(len(results['artists']['items']) > 0)
|
||||
self.assertTrue(results['artists']['items'][0]['name'] == 'Weezer')
|
||||
|
||||
def test_artist_search_with_multiple_markets(self):
|
||||
TOTAL = 3
|
||||
results_single = self.spotify.search(q='weezer', type='artist', market='US')
|
||||
results_multiple = self.spotify.search(q='weezer', type='artist',
|
||||
market=['GB', 'US', 'AU'])
|
||||
results_all = self.spotify.search(q='weezer', type='artist', market="ALL")
|
||||
results_limited = self.spotify.search(q='weezer', type='artist',
|
||||
market=['GB', 'US', 'AU'], total=TOTAL)
|
||||
|
||||
results_tuple = self.spotify.search(q='weezer', type='artist',
|
||||
market=('GB', 'US', 'AU'), total=TOTAL)
|
||||
|
||||
self.assertTrue('artists' in results_multiple)
|
||||
self.assertTrue('artists' in results_all)
|
||||
self.assertTrue('artists' in results_limited)
|
||||
self.assertTrue('artists' in results_tuple)
|
||||
|
||||
self.assertTrue(len(results_multiple['artists']['items']) > 0)
|
||||
self.assertTrue(len(results_all['artists']['items']) > 0)
|
||||
self.assertTrue(len(results_limited['artists']['items']) > 0)
|
||||
self.assertTrue(len(results_tuple['artists']['items']) > 0)
|
||||
|
||||
self.assertTrue(len(results_all['artists']['items']) >
|
||||
len(results_multiple['artists']['items']))
|
||||
self.assertTrue(len(results_multiple['artists']['items'])
|
||||
> len(results_single['artists']['items']))
|
||||
|
||||
self.assertTrue(results_multiple['artists']['items'][0]['name'] == 'Weezer')
|
||||
self.assertTrue(results_all['artists']['items'][0]['name'] == 'Weezer')
|
||||
self.assertTrue(results_limited['artists']['items'][0]['name'] == 'Weezer')
|
||||
self.assertTrue(results_tuple['artists']['items'][0]['name'] == 'Weezer')
|
||||
|
||||
self.assertTrue(len(results_limited['artists']['items']) <= TOTAL)
|
||||
|
||||
def test_artist_albums(self):
|
||||
results = self.spotify.artist_albums(self.weezer_urn)
|
||||
self.assertTrue('items' in results)
|
||||
|
||||
Reference in new issue
Block a user