Add tests for global categories, releases, fix bugged tests (#893)

This commit is contained in:
Kevin Sekuj 2022-11-26 01:29:53 -08:00 committed by GitHub
parent edcd322845
commit 5201f58247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -10,12 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Integration tests via GHA (non-user endpoints) - Integration tests via GHA (non-user endpoints)
- Unit tests for new releases, passing limit parameter with minimum and maximum values of 1 and 50
- Unit tests for categories, omitting country code to test global releases
### Fixed ### Fixed
- Incorrect category_id input for test_category - Incorrect category_id input for test_category
- Assertion value for test_categories_limit_low and test_categories_limit_high - Assertion value for test_categories_limit_low and test_categories_limit_high
- Pin Github Actions Runner to Ubuntu 20 for Py27 - Pin Github Actions Runner to Ubuntu 20 for Py27
- Fixed potential error where `found` variable in `test_artist_related_artists` is undefined if for loop never evaluates to true
- Fixed false positive test `test_new_releases` which looks up the wrong property of the JSON response object and always evaluates to true
## [2.21.0] - 2022-09-26 ## [2.21.0] - 2022-09-26

View File

@ -158,6 +158,8 @@ class AuthTestSpotipy(unittest.TestCase):
results = self.spotify.artist_related_artists(self.weezer_urn) results = self.spotify.artist_related_artists(self.weezer_urn)
self.assertTrue('artists' in results) self.assertTrue('artists' in results)
self.assertTrue(len(results['artists']) == 20) self.assertTrue(len(results['artists']) == 20)
found = False
for artist in results['artists']: for artist in results['artists']:
if artist['name'] == 'Jimmy Eat World': if artist['name'] == 'Jimmy Eat World':
found = True found = True

View File

@ -364,6 +364,10 @@ class SpotipyBrowseApiTests(unittest.TestCase):
response = self.spotify.categories(country='US') response = self.spotify.categories(country='US')
self.assertGreater(len(response['categories']), 0) self.assertGreater(len(response['categories']), 0)
def test_categories_global(self):
response = self.spotify.categories()
self.assertGreater(len(response['categories']), 0)
def test_categories_locale(self): def test_categories_locale(self):
response = self.spotify.categories(locale='en_US') response = self.spotify.categories(locale='en_US')
self.assertGreater(len(response['categories']), 0) self.assertGreater(len(response['categories']), 0)
@ -405,7 +409,15 @@ class SpotipyBrowseApiTests(unittest.TestCase):
def test_new_releases(self): def test_new_releases(self):
response = self.spotify.new_releases() response = self.spotify.new_releases()
self.assertGreater(len(response['albums']), 0) self.assertGreater(len(response['albums']['items']), 0)
def test_new_releases_limit_low(self):
response = self.spotify.new_releases(limit=1)
self.assertEqual(len(response['albums']['items']), 1)
def test_new_releases_limit_high(self):
response = self.spotify.new_releases(limit=50)
self.assertLessEqual(len(response['albums']['items']), 50)
def test_featured_releases(self): def test_featured_releases(self):
response = self.spotify.featured_playlists() response = self.spotify.featured_playlists()