diff --git a/tests/json/steering-api-v1-playout.json b/tests/json/steering-api-v1-playout.json index d35966e5e376c89c95e04e56630c89d93fd2b6b2..d91bc743ed85938274233c0f1847c9d2907490d4 100644 --- a/tests/json/steering-api-v1-playout.json +++ b/tests/json/steering-api-v1-playout.json @@ -78,5 +78,25 @@ "showMusicFocus": "", "showLanguages": "", "showFundingCategory": "Standard" + }, + { + "id": 21, + "start": "2023-05-16T15:10:00", + "end": "2023-05-16T15:50:00", + "title": "Pepi's Polka III", + "scheduleId": 20, + "repetitionOfId": null, + "playlistId": null, + "scheduleDefaultPlaylistId": null, + "showDefaultPlaylistId": null, + "showId": 1, + "showName": "Musikprogramm", + "showHosts": "Musikredaktion", + "showType": "Unmoderiertes Musikprogramm", + "showCategories": "", + "showTopics": "", + "showMusicFocus": "", + "showLanguages": "", + "showFundingCategory": "Standard" } ] \ No newline at end of file diff --git a/tests/test_scheduling_api_fetcher.py b/tests/test_scheduling_api_fetcher.py index d5c831dca3f4dcaa5f8ba7bbad26036b53124ffc..ca4cb7b54f8bd9488df60764de6e72cda24c4776 100644 --- a/tests/test_scheduling_api_fetcher.py +++ b/tests/test_scheduling_api_fetcher.py @@ -154,7 +154,7 @@ class TestSchedulingApiFetcher(unittest.TestCase): # Test Timetable self.assertEqual(ApiResult, type(response)) self.assertEqual(0, response.code) - self.assertEqual(3, len(response.timeslots)) + self.assertEqual(4, len(response.timeslots)) # Test Timeslot 1 ts1: Timeslot = response.timeslots[0] @@ -298,6 +298,36 @@ class TestSchedulingApiFetcher(unittest.TestCase): self.assertIsNotNone(pl_items[4].next) self.assertIsNone(pl_items[5].next) + @mock.patch("aura_engine.base.api.requests.get", side_effect=mocked_requests_get) + def test_fetch_timeslot_without_playlists(self, mock_get): + print(self._testMethodName) + + # Clear cache to keep test cases isolated + self.api_fetcher.api.prune_cache_dir() + + # Start fetching thread + self.api_fetcher.start() + response: ApiResult = self.api_fetcher.fetch() + print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print("[test_fetch_data] response message: " + str(response.message)) + if response.exception: + print("[test_fetch_data] response exception: \n" + str(response.exception)) + + # Test Timetable + self.assertEqual(ApiResult, type(response)) + self.assertEqual(0, response.code) + self.assertEqual(4, len(response.timeslots)) + + # Test Timeslot 1 + ts1: Timeslot = response.timeslots[3] + self.assertEqual(1, ts1.show.id) + self.assertEqual("Pepi's Polka III", ts1.episode.title) + + # Test Timeslot 1 - there are no playlists assigned + self.assertIsNone(ts1.playlist.timeslot) + self.assertIsNone(ts1.playlist.schedule) + self.assertIsNone(ts1.playlist.show) + @mock.patch("aura_engine.base.api.requests.get", side_effect=mocked_requests_get) def test_fetch_with_expanded_duration(self, mock_get): print(self._testMethodName) @@ -316,7 +346,7 @@ class TestSchedulingApiFetcher(unittest.TestCase): # Test Timetable self.assertEqual(ApiResult, type(response)) self.assertEqual(0, response.code) - self.assertEqual(3, len(response.timeslots)) + self.assertEqual(4, len(response.timeslots)) # Test Timeslot 3 ts1: Timeslot = response.timeslots[2] diff --git a/tests/test_scheduling_api_steering.py b/tests/test_scheduling_api_steering.py index 683170987619d6c6daa9eeb9e20eb2026cbdb4a4..4042feac7c993f0eab26cebfcb6b08c77ccf5560 100644 --- a/tests/test_scheduling_api_steering.py +++ b/tests/test_scheduling_api_steering.py @@ -53,7 +53,7 @@ class TestApiSteering(unittest.TestCase): timetable.append(t) self.assertIsNotNone(timetable) - self.assertEqual(4, len(timetable)) + self.assertEqual(5, len(timetable)) t1 = timetable[0] self.assertEqual(17, t1.id)