Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
d327bbdc
Commit
d327bbdc
authored
1 year ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
test: timetable renderer
parent
f13ad211
No related branches found
No related tags found
1 merge request
!35
ORM-less scheduling
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_scheduling_utils.py
+70
-4
70 additions, 4 deletions
tests/test_scheduling_utils.py
with
70 additions
and
4 deletions
tests/test_scheduling_utils.py
+
70
−
4
View file @
d327bbdc
...
@@ -20,8 +20,20 @@
...
@@ -20,8 +20,20 @@
import
unittest
import
unittest
from
aura_engine.base.config
import
AuraConfig
from
aura_engine.base.config
import
AuraConfig
from
aura_engine.scheduling.domain
import
PlaylistItem
from
aura_engine.base.utils
import
SimpleUtil
as
SU
from
aura_engine.scheduling.utils
import
M3UPlaylistProcessor
from
aura_engine.scheduling.domain
import
Playlist
,
PlaylistItem
,
Timeslot
from
aura_engine.scheduling.programme
import
TimetableService
from
aura_engine.scheduling.utils
import
M3UPlaylistProcessor
,
TimetableRenderer
class
MockedScheduler
:
timetable
:
TimetableService
def
__init__
(
self
,
timetable
:
[
Timeslot
]):
self
.
timetable
=
timetable
def
get_timetable
(
self
)
->
TimetableService
:
return
self
.
timetable
class
TestSchedulingUtils
(
unittest
.
TestCase
):
class
TestSchedulingUtils
(
unittest
.
TestCase
):
...
@@ -31,6 +43,7 @@ class TestSchedulingUtils(unittest.TestCase):
...
@@ -31,6 +43,7 @@ class TestSchedulingUtils(unittest.TestCase):
config
=
None
config
=
None
m3u
=
None
m3u
=
None
timetable
:
TimetableService
# Setup and teardown
# Setup and teardown
...
@@ -39,6 +52,9 @@ class TestSchedulingUtils(unittest.TestCase):
...
@@ -39,6 +52,9 @@ class TestSchedulingUtils(unittest.TestCase):
self
.
m3u
=
M3UPlaylistProcessor
()
self
.
m3u
=
M3UPlaylistProcessor
()
self
.
m3u
.
playlist_folder
=
"
./tests/m3u/
"
self
.
m3u
.
playlist_folder
=
"
./tests/m3u/
"
cache_location
=
self
.
config
.
get
(
"
cache_dir
"
)
self
.
timetable
=
TimetableService
(
cache_location
)
def
tearDown
(
self
):
def
tearDown
(
self
):
pass
pass
...
@@ -69,13 +85,63 @@ class TestSchedulingUtils(unittest.TestCase):
...
@@ -69,13 +85,63 @@ class TestSchedulingUtils(unittest.TestCase):
def
test_spread_no_m3u_playlist
(
self
):
def
test_spread_no_m3u_playlist
(
self
):
print
(
self
.
_testMethodName
)
print
(
self
.
_testMethodName
)
print
(
self
.
_testMethodName
)
item
=
PlaylistItem
(
"
playlist://404.m3u
"
,
None
,
100
,
PlaylistItem
.
Metadata
(
""
,
""
,
""
))
item
=
PlaylistItem
(
"
playlist://404.m3u
"
,
None
,
100
,
PlaylistItem
.
Metadata
(
""
,
""
,
""
))
items
=
self
.
m3u
.
spread
(
item
)
items
=
self
.
m3u
.
spread
(
item
)
self
.
assertEqual
(
0
,
len
(
items
))
self
.
assertEqual
(
0
,
len
(
items
))
def
test_timetable_renderer
(
self
):
print
(
self
.
_testMethodName
)
# Build timeslots
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
)
# Set playlist for timeslot 2 (currently playing)
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
)
delta
=
PlaylistItem
(
"
delta.flac
"
,
200
,
100
,
None
)
epsilon
=
PlaylistItem
(
"
epsilon.flac
"
,
300
,
100
,
None
)
pl
.
add
(
alpha
)
pl
.
add
(
beta
)
pl
.
add
(
gamma
)
pl
.
add
(
delta
)
pl
.
add
(
epsilon
)
ts2
.
set_playlists
(
None
,
pl
,
None
)
# Set playlist for timeslot 3 (playing next)
pl
=
Playlist
(
"
555
"
,
"
Playlist Y
"
,
False
)
alpha
=
PlaylistItem
(
"
red.flac
"
,
20
,
100
,
None
)
beta
=
PlaylistItem
(
"
green.flac
"
,
100
,
100
,
None
)
gamma
=
PlaylistItem
(
"
blue.flac
"
,
20
,
100
,
None
)
pl
.
add
(
alpha
)
pl
.
add
(
beta
)
pl
.
add
(
gamma
)
ts3
.
set_playlists
(
pl
,
None
,
None
)
timeslots
=
[
ts1
,
ts2
,
ts3
,
ts4
]
self
.
timetable
.
timetable
=
timeslots
scheduler
=
MockedScheduler
(
self
.
timetable
)
# Build and display report
tr
=
TimetableRenderer
(
scheduler
)
report
=
tr
.
get_ascii_timeslots
()
print
(
report
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
unittest
.
main
()
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment