From 18f14660a02c5639e0e4c56b438080e5fa907a21 Mon Sep 17 00:00:00 2001 From: mattrost Date: Mon, 23 May 2022 13:43:55 -0700 Subject: [PATCH 1/5] Added test_categories_country to use optional country selection for categories method. --- tests/integration/test_user_endpoints.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index 0b5c2eb3..10bbf073 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -368,6 +368,10 @@ def test_category_playlists(self): response = self.spotify.category_playlists(category_id=cat_id) self.assertGreater(len(response['playlists']["items"]), 0) + def test_categories_country(self): + response = self.spotify.categories(country='US') + self.assertGreater(len(response['categories']), 0) + def test_new_releases(self): response = self.spotify.new_releases() self.assertGreater(len(response['albums']), 0) From 935878cbf2aaa9b330ea9fdd9d6689637a1b8b8e Mon Sep 17 00:00:00 2001 From: mattrost Date: Mon, 23 May 2022 13:44:28 -0700 Subject: [PATCH 2/5] Added test_categories_locale for testing locale method of categories. --- tests/integration/test_user_endpoints.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index 10bbf073..46faac8f 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -372,6 +372,10 @@ def test_categories_country(self): response = self.spotify.categories(country='US') self.assertGreater(len(response['categories']), 0) + def test_categories_locale(self): + response = self.spotify.categories(locale='en_US') + self.assertGreater(len(response['categories']), 0) + def test_new_releases(self): response = self.spotify.new_releases() self.assertGreater(len(response['albums']), 0) From ac11cc89eb154fa9d21830cfab4b39bc65c340a1 Mon Sep 17 00:00:00 2001 From: mattrost Date: Mon, 23 May 2022 13:45:11 -0700 Subject: [PATCH 3/5] Added test_categories_limit_low and test_categories_limit_high to test the limit method of categories for edge cases. --- tests/integration/test_user_endpoints.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index 46faac8f..782d45d8 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -376,6 +376,14 @@ def test_categories_locale(self): response = self.spotify.categories(locale='en_US') self.assertGreater(len(response['categories']), 0) + def test_categories_limit_low(self): + response = self.spotify.categories(limit=1) + self.assertEqual(len(response['categories']), 1) + + def test_categories_limit_high(self): + response = self.spotify.categories(limit=50) + self.assertEqual(len(response['categories']), 50) + def test_new_releases(self): response = self.spotify.new_releases() self.assertGreater(len(response['albums']), 0) From 5a535ec2f482adca7a64525c887cef7a2a2d0356 Mon Sep 17 00:00:00 2001 From: mattrost Date: Mon, 23 May 2022 13:56:43 -0700 Subject: [PATCH 4/5] Rearranged for flow --- tests/integration/test_user_endpoints.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index 782d45d8..be1932f6 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -359,15 +359,6 @@ def test_categories(self): response = self.spotify.categories() self.assertGreater(len(response['categories']), 0) - def test_category_playlists(self): - response = self.spotify.categories() - category = 'rock' - for cat in response['categories']['items']: - cat_id = cat['id'] - if cat_id == category: - response = self.spotify.category_playlists(category_id=cat_id) - self.assertGreater(len(response['playlists']["items"]), 0) - def test_categories_country(self): response = self.spotify.categories(country='US') self.assertGreater(len(response['categories']), 0) @@ -384,6 +375,16 @@ def test_categories_limit_high(self): response = self.spotify.categories(limit=50) self.assertEqual(len(response['categories']), 50) + def test_category_playlists(self): + response = self.spotify.categories() + category = 'rock' + for cat in response['categories']['items']: + cat_id = cat['id'] + if cat_id == category: + response = self.spotify.category_playlists(category_id=cat_id) + self.assertGreater(len(response['playlists']["items"]), 0) + + def test_new_releases(self): response = self.spotify.new_releases() self.assertGreater(len(response['albums']), 0) From 53acfb0343c996b1b3444ed92ac99b3265448c8a Mon Sep 17 00:00:00 2001 From: mattrost Date: Mon, 23 May 2022 14:00:59 -0700 Subject: [PATCH 5/5] Added test_category_playlists_limit_low and test_category_playlists_limit_high for testing the limit method. --- tests/integration/test_user_endpoints.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index be1932f6..09b57b35 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -373,7 +373,7 @@ def test_categories_limit_low(self): def test_categories_limit_high(self): response = self.spotify.categories(limit=50) - self.assertEqual(len(response['categories']), 50) + self.assertLessEqual(len(response['categories']), 50) def test_category_playlists(self): response = self.spotify.categories() @@ -384,6 +384,24 @@ def test_category_playlists(self): response = self.spotify.category_playlists(category_id=cat_id) self.assertGreater(len(response['playlists']["items"]), 0) + def test_category_playlists_limit_low(self): + response = self.spotify.categories() + category = 'rock' + for cat in response['categories']['items']: + cat_id = cat['id'] + if cat_id == category: + response = self.spotify.category_playlists(category_id=cat_id, limit=1) + self.assertEqual(len(response['categories']['items']), 1) + + def test_category_playlists_limit_high(self): + response = self.spotify.categories() + category = 'rock' + for cat in response['categories']['items']: + cat_id = cat['id'] + if cat_id == category: + response = self.spotify.category_playlists(category_id=cat_id, limit=50) + self.assertLessEqual(len(response['categories']['items']), 50) + def test_new_releases(self): response = self.spotify.new_releases()