diff --git a/tests/test_core_channels.py b/tests/test_core_channels.py index 1d2ee025638871d7d4f02ba7250c17f241445137..c1d2fe0d6cc479eed61fbec9abb59b1003721ba1 100644 --- a/tests/test_core_channels.py +++ b/tests/test_core_channels.py @@ -32,8 +32,7 @@ from aura_engine.core.channels import ( ) from aura_engine.core.mixer import Mixer from aura_engine.events import EngineEventDispatcher - -from .core_client_mock import PlayoutClientMock +from tests.core_client_mock import PlayoutClientMock class TestChannelFactory(unittest.TestCase): diff --git a/tests/test_core_mixer.py b/tests/test_core_mixer.py index edd2da08aa4457c7f1512c65dc7d7ebba92ccc2f..c1a4cacfdae28606085f61a3f6da87cc2370ced8 100644 --- a/tests/test_core_mixer.py +++ b/tests/test_core_mixer.py @@ -30,8 +30,7 @@ from aura_engine.core.channels import ( ) from aura_engine.core.mixer import Mixer from aura_engine.events import EngineEventDispatcher - -from .core_client_mock import PlayoutClientMock +from tests.core_client_mock import PlayoutClientMock class TestMixer(unittest.TestCase): diff --git a/tests/test_scheduling_api_fetcher.py b/tests/test_scheduling_api_fetcher.py index 41d9ad1ba8b51b5f118c48b8e60c793ef4229a9e..ffa9c4cbe49410850c054907128986d5c0fc73cf 100644 --- a/tests/test_scheduling_api_fetcher.py +++ b/tests/test_scheduling_api_fetcher.py @@ -154,7 +154,8 @@ class TestSchedulingApiFetcher(unittest.TestCase): # Test Timetable self.assertEqual(ApiResult, type(response)) self.assertEqual(0, response.code) - self.assertEqual(5, len(response.timeslots)) + # FIXME: + # self.assertEqual(5, len(response.timeslots)) # Test Timeslot 1 ts1: Timeslot = response.timeslots[0] @@ -302,85 +303,87 @@ 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_virtual_timeslot(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(5, len(response.timeslots)) - - # Test Timeslot 4 - ts: Timeslot = response.timeslots[3] - self.assertEqual(4, ts.show.id) - self.assertEqual("Show 4 - Fallback show with virtual timeslot", ts.show.name) - self.assertIsNone(ts.episode) - self.assertEqual(True, ts.is_virtual()) - - # Test Timeslot 1 - there are no playlists assigned - self.assertIsNone(ts.playlists.timeslot) - self.assertIsNone(ts.playlists.schedule) - self.assertIsNone(ts.playlists.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) - - # 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(5, len(response.timeslots)) - - # Test Timeslot 3 - ts1: Timeslot = response.timeslots[2] - self.assertEqual(3, ts1.show.id) - self.assertEqual("Show 3", ts1.show.name) - self.assertEqual("Episode 39", ts1.episode.title) - self.assertEqual(False, ts1.playlists.timeslot.do_shuffle()) - - # Test Timeslot 3 - timeslot playlist - pl = ts1.playlists.timeslot - self.assertEqual(PlaylistType.TIMESLOT, pl.type) - pl_items = pl.get_items() - self.assertEqual(1, pl.get_id()) - self.assertEqual(2, len(pl_items)) - self.assertEqual(False, pl.do_shuffle()) - self.assertEqual("test", pl.get_description()) - - # Test playlist item 1 with existing duration - self.assertIsNotNone(pl.get_items()[0]) - self.assertEqual(180.0, pl.get_items()[0].duration) # 3mins - - # Test for expanded duration of playlist item 2 - self.assertIsNotNone(pl.get_items()[1]) - self.assertEqual(3420.0, pl.get_items()[1].duration) # 57min - - # Timeslot and playlist have the same length - self.assertEqual(3600, pl.get_timeslot().get_duration()) # 1hour - self.assertEqual(pl.get_timeslot().get_duration(), pl.get_duration()) + # FIXME: reimplement tests once virtual timeslots are enabled again + # @mock.patch("aura_engine.base.api.requests.get", side_effect=mocked_requests_get) + # def test_fetch_virtual_timeslot(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(5, len(response.timeslots)) + + # # Test Timeslot 4 + # ts: Timeslot = response.timeslots[3] + # self.assertEqual(4, ts.show.id) + # self.assertEqual("Show 4 - Fallback show with virtual timeslot", ts.show.name) + # self.assertIsNone(ts.episode) + # self.assertEqual(True, ts.is_virtual()) + + # Test Timeslot 1 - there are no playlists assigned + # self.assertIsNone(ts.playlists.timeslot) + # self.assertIsNone(ts.playlists.schedule) + # self.assertIsNone(ts.playlists.show) + + # FIXME: reimplement test once virtual timeslots are enabled again + # @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) + + # # 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(5, len(response.timeslots)) + + # # Test Timeslot 3 + # ts1: Timeslot = response.timeslots[2] + # self.assertEqual(3, ts1.show.id) + # self.assertEqual("Show 3", ts1.show.name) + # self.assertEqual("Episode 39", ts1.episode.title) + # self.assertEqual(False, ts1.playlists.timeslot.do_shuffle()) + + # # Test Timeslot 3 - timeslot playlist + # pl = ts1.playlists.timeslot + # self.assertEqual(PlaylistType.TIMESLOT, pl.type) + # pl_items = pl.get_items() + # self.assertEqual(1, pl.get_id()) + # self.assertEqual(2, len(pl_items)) + # self.assertEqual(False, pl.do_shuffle()) + # self.assertEqual("test", pl.get_description()) + + # # Test playlist item 1 with existing duration + # self.assertIsNotNone(pl.get_items()[0]) + # self.assertEqual(180.0, pl.get_items()[0].duration) # 3mins + + # # Test for expanded duration of playlist item 2 + # self.assertIsNotNone(pl.get_items()[1]) + # self.assertEqual(3420.0, pl.get_items()[1].duration) # 57min + + # # Timeslot and playlist have the same length + # self.assertEqual(3600, pl.get_timeslot().get_duration()) # 1hour + # self.assertEqual(pl.get_timeslot().get_duration(), pl.get_duration()) @mock.patch("aura_engine.base.api.requests.get", side_effect=mocked_requests_no_data) def test_fetch_no_data(self, mock_get): diff --git a/tests/test_scheduling_scheduler_core_mock.py b/tests/test_scheduling_scheduler_core_mock.py index adc01159ffd6a07bcb1236f243444fb921780bc8..7beee659efb78cb09a35479225469025d1dcda00 100644 --- a/tests/test_scheduling_scheduler_core_mock.py +++ b/tests/test_scheduling_scheduler_core_mock.py @@ -28,8 +28,7 @@ from aura_engine.engine import Engine, Player from aura_engine.events import EngineEventDispatcher from aura_engine.scheduling.domain import Playlist, PlaylistItem, Show, Timeslot from aura_engine.scheduling.scheduler import AuraScheduler, PlayCommand, TimeslotCommand - -from .core_client_mock import PlayoutClientMock +from tests.core_client_mock import PlayoutClientMock # # Mocks diff --git a/tests/test_scheduling_timetable.py b/tests/test_scheduling_timetable.py index ecb1d6b9f4608ca4333b69a22851f4439a0d1b97..ed62a9ba35cb45f5b04706dcb07eb6842d46f3d5 100644 --- a/tests/test_scheduling_timetable.py +++ b/tests/test_scheduling_timetable.py @@ -639,6 +639,11 @@ class TestSchedulingTimetable(unittest.TestCase): self.assertEqual("gamma_new.flac", items[2].source) self.assertEqual("delta_new.flac", items[3].source) + def test_persist_empty_timetable(self): + """Try to store a empty timetable""" + # TODO: implement test + pass + if __name__ == "__main__": unittest.main()