Skip to content

Commit

Permalink
Add tests for global categories, releases, fix bugged tests (#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsekuj committed Nov 26, 2022
1 parent edcd322 commit 5201f58
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -10,12 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- 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

- Incorrect category_id input for test_category
- Assertion value for test_categories_limit_low and test_categories_limit_high
- 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

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/non_user_endpoints/test.py
Expand Up @@ -158,6 +158,8 @@ def test_artist_related_artists(self):
results = self.spotify.artist_related_artists(self.weezer_urn)
self.assertTrue('artists' in results)
self.assertTrue(len(results['artists']) == 20)

found = False
for artist in results['artists']:
if artist['name'] == 'Jimmy Eat World':
found = True
Expand Down
14 changes: 13 additions & 1 deletion tests/integration/user_endpoints/test.py
Expand Up @@ -364,6 +364,10 @@ def test_categories_country(self):
response = self.spotify.categories(country='US')
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):
response = self.spotify.categories(locale='en_US')
self.assertGreater(len(response['categories']), 0)
Expand Down Expand Up @@ -405,7 +409,15 @@ def test_category_playlists_limit_high(self):

def test_new_releases(self):
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):
response = self.spotify.featured_playlists()
Expand Down

0 comments on commit 5201f58

Please sign in to comment.