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

test: get current item

parent 3d6e383b
No related branches found
No related tags found
1 merge request!35ORM-less scheduling
...@@ -28,7 +28,7 @@ from aura_engine.base.api import SimpleCachedRestApi ...@@ -28,7 +28,7 @@ from aura_engine.base.api import SimpleCachedRestApi
from aura_engine.base.config import AuraConfig from aura_engine.base.config import AuraConfig
from aura_engine.base.utils import SimpleUtil as SU from aura_engine.base.utils import SimpleUtil as SU
from aura_engine.scheduling.api import ApiFetcher from aura_engine.scheduling.api import ApiFetcher
from aura_engine.scheduling.domain import PlaylistType, Timeslot from aura_engine.scheduling.domain import Playlist, PlaylistItem, PlaylistType, Timeslot
from aura_engine.scheduling.programme import TimetableService from aura_engine.scheduling.programme import TimetableService
...@@ -209,6 +209,38 @@ class TestSchedulingTimetable(unittest.TestCase): ...@@ -209,6 +209,38 @@ class TestSchedulingTimetable(unittest.TestCase):
next = self.timetable.get_next_timeslots() next = self.timetable.get_next_timeslots()
self.assertEqual(0, len(next)) self.assertEqual(0, len(next))
def test_get_current_item(self):
print(self._testMethodName)
now = SU.timestamp()
ts1 = Timeslot(
id=1, repetition_id=None, start=now - 180, end=now - 120, show=None, episode=None
)
ts2 = Timeslot(
id=1, repetition_id=None, start=now - 120, end=now + 120, show=None, episode=None
)
ts3 = Timeslot(
id=1, repetition_id=None, start=now + 120, end=now + 180, show=None, episode=None
)
ts4 = Timeslot(
id=1, repetition_id=None, start=now + 180, end=now + 360, show=None, episode=None
)
pl = Playlist("999", "Playlist X", False)
alpha = PlaylistItem("alpha.flac", 20, 100, None)
beta = PlaylistItem("beta.flac", 100, 100, None)
gamma = PlaylistItem("gamma.flac", 20, 100, None)
pl.add(alpha)
pl.add(beta)
pl.add(gamma)
ts2.set_playlists(pl, None, None)
self.timetable.timetable = [ts1, ts2, ts3, ts4]
current = self.timetable.get_current_item()
print(f"Current item is '{current.source}'")
self.assertEqual(beta, current)
def test_is_timeslot_in_window(self): def test_is_timeslot_in_window(self):
print(self._testMethodName) print(self._testMethodName)
# Expecting a configured schedluing window of T1(-60) - T2(-60) seconds. # Expecting a configured schedluing window of T1(-60) - T2(-60) seconds.
...@@ -243,6 +275,7 @@ class TestSchedulingTimetable(unittest.TestCase): ...@@ -243,6 +275,7 @@ class TestSchedulingTimetable(unittest.TestCase):
def test_timetable_merge(self): def test_timetable_merge(self):
print(self._testMethodName) print(self._testMethodName)
# @mock.patch("aura_engine.scheduling.programme.api_fetcher", side_effect=mocked_fetch)
@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_data(self, mock_get): def test_fetch_data(self, mock_get):
print(self._testMethodName) print(self._testMethodName)
......
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