Skip to content
Snippets Groups Projects
Commit 018ba26b authored by David Trattnig's avatar David Trattnig
Browse files

test: timeslot without any playlist

parent 11d43c33
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
...@@ -78,5 +78,25 @@ ...@@ -78,5 +78,25 @@
"showMusicFocus": "", "showMusicFocus": "",
"showLanguages": "", "showLanguages": "",
"showFundingCategory": "Standard" "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
...@@ -154,7 +154,7 @@ class TestSchedulingApiFetcher(unittest.TestCase): ...@@ -154,7 +154,7 @@ class TestSchedulingApiFetcher(unittest.TestCase):
# Test Timetable # Test Timetable
self.assertEqual(ApiResult, type(response)) self.assertEqual(ApiResult, type(response))
self.assertEqual(0, response.code) self.assertEqual(0, response.code)
self.assertEqual(3, len(response.timeslots)) self.assertEqual(4, len(response.timeslots))
# Test Timeslot 1 # Test Timeslot 1
ts1: Timeslot = response.timeslots[0] ts1: Timeslot = response.timeslots[0]
...@@ -298,6 +298,36 @@ class TestSchedulingApiFetcher(unittest.TestCase): ...@@ -298,6 +298,36 @@ class TestSchedulingApiFetcher(unittest.TestCase):
self.assertIsNotNone(pl_items[4].next) self.assertIsNotNone(pl_items[4].next)
self.assertIsNone(pl_items[5].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) @mock.patch("aura_engine.base.api.requests.get", side_effect=mocked_requests_get)
def test_fetch_with_expanded_duration(self, mock_get): def test_fetch_with_expanded_duration(self, mock_get):
print(self._testMethodName) print(self._testMethodName)
...@@ -316,7 +346,7 @@ class TestSchedulingApiFetcher(unittest.TestCase): ...@@ -316,7 +346,7 @@ class TestSchedulingApiFetcher(unittest.TestCase):
# Test Timetable # Test Timetable
self.assertEqual(ApiResult, type(response)) self.assertEqual(ApiResult, type(response))
self.assertEqual(0, response.code) self.assertEqual(0, response.code)
self.assertEqual(3, len(response.timeslots)) self.assertEqual(4, len(response.timeslots))
# Test Timeslot 3 # Test Timeslot 3
ts1: Timeslot = response.timeslots[2] ts1: Timeslot = response.timeslots[2]
......
...@@ -53,7 +53,7 @@ class TestApiSteering(unittest.TestCase): ...@@ -53,7 +53,7 @@ class TestApiSteering(unittest.TestCase):
timetable.append(t) timetable.append(t)
self.assertIsNotNone(timetable) self.assertIsNotNone(timetable)
self.assertEqual(4, len(timetable)) self.assertEqual(5, len(timetable))
t1 = timetable[0] t1 = timetable[0]
self.assertEqual(17, t1.id) self.assertEqual(17, t1.id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment