diff --git a/src/services/oracle.py b/src/services/oracle.py index 9217cd3..dda7b7b 100644 --- a/src/services/oracle.py +++ b/src/services/oracle.py @@ -19,13 +19,14 @@ def get_next_production( if not production_list: response = self.tmdb.get_list(TMDB_MCU_LIST) - production_list = response["items"] - current_page = response["page"] - total_num_pages = response["total_pages"] - - if current_page < total_num_pages: - response = self.tmdb.get_list(TMDB_MCU_LIST, total_num_pages) + if response: production_list = response["items"] + current_page = response["page"] + total_num_pages = response["total_pages"] + + if current_page < total_num_pages: + response = self.tmdb.get_list(TMDB_MCU_LIST, total_num_pages) + production_list = response["items"] if production_list: if not desired_date: diff --git a/tests/test_tmdb.py b/tests/test_tmdb.py index af6717e..26c6cea 100644 --- a/tests/test_tmdb.py +++ b/tests/test_tmdb.py @@ -11,7 +11,7 @@ def setUp(self): ) def test_send_request(self): - expected_data = "https://api.themoviedb.org/3/lists?api_key=CXdrQrBgAL3HET3mMmMt&language=en-CA" + expected_data = "https://api.themoviedb.org/3/lists?api_key=CXdrQrBgAL3HET3mMmMt&language=en-CA&page=1" data = self.tmdb.send_request("lists").url self.assertEqual(data, expected_data)