From 5201f58247f863dbe5eb8048684fa2f9e8e0a849 Mon Sep 17 00:00:00 2001 From: Kevin Sekuj <68984611+kevinsekuj@users.noreply.github.com> Date: Sat, 26 Nov 2022 01:29:53 -0800 Subject: [PATCH] Add tests for global categories, releases, fix bugged tests (#893) --- CHANGELOG.md | 4 ++++ tests/integration/non_user_endpoints/test.py | 2 ++ tests/integration/user_endpoints/test.py | 14 +++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 617dec86..26f9ed5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/tests/integration/non_user_endpoints/test.py b/tests/integration/non_user_endpoints/test.py index 1222c0b5..96ee4da9 100644 --- a/tests/integration/non_user_endpoints/test.py +++ b/tests/integration/non_user_endpoints/test.py @@ -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 diff --git a/tests/integration/user_endpoints/test.py b/tests/integration/user_endpoints/test.py index 68566586..d2568499 100644 --- a/tests/integration/user_endpoints/test.py +++ b/tests/integration/user_endpoints/test.py @@ -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) @@ -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()