Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
steering
Commits
3541fc61
Verified
Commit
3541fc61
authored
8 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: add playout tests for one week
parent
2da9f016
No related branches found
No related tags found
1 merge request
!52
new program endpoint
Pipeline
#8324
passed
8 months ago
Stage: check
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/tests/test_playout.py
+58
-4
58 additions, 4 deletions
program/tests/test_playout.py
with
58 additions
and
4 deletions
program/tests/test_playout.py
+
58
−
4
View file @
3541fc61
from
datetime
import
datetime
,
timedelta
from
itertools
import
pairwise
import
pytest
import
pytest
from
conftest
import
create_daily_schedule
from
conftest
import
create_daily_schedule
...
@@ -5,11 +8,15 @@ from conftest import create_daily_schedule
...
@@ -5,11 +8,15 @@ from conftest import create_daily_schedule
pytestmark
=
pytest
.
mark
.
django_db
pytestmark
=
pytest
.
mark
.
django_db
def
url
(
include_virtual
=
False
):
def
url
(
include_virtual
=
False
,
start
=
None
,
end
=
None
):
if
include_virtual
:
if
include_virtual
and
start
and
end
:
return
f
"
/api/v1/program/playout/?include_virtual=true&start=
{
start
}
&end=
{
end
}
"
elif
start
and
end
:
return
f
"
/api/v1/program/playout/?start=
{
start
}
&end=
{
end
}
"
elif
include_virtual
:
return
"
/api/v1/program/playout/?include_virtual=true
"
return
"
/api/v1/program/playout/?include_virtual=true
"
else
:
return
"
/api/v1/program/playout/
"
return
"
/api/v1/program/playout/
"
def
assert_entry
(
entry
,
show
)
->
None
:
def
assert_entry
(
entry
,
show
)
->
None
:
...
@@ -49,6 +56,21 @@ def test_playout(admin_api_client, api_client, daily_rrule, show):
...
@@ -49,6 +56,21 @@ def test_playout(admin_api_client, api_client, daily_rrule, show):
assert_entry
(
response
.
json
()[
0
],
show
)
assert_entry
(
response
.
json
()[
0
],
show
)
def
test_playout_one_week
(
admin_api_client
,
api_client
,
daily_rrule
,
show
):
create_daily_schedule
(
admin_api_client
,
daily_rrule
,
show
)
now
=
datetime
.
now
()
in_one_week
=
now
+
timedelta
(
days
=
7
)
response
=
api_client
.
get
(
url
(
start
=
now
.
isoformat
(),
end
=
in_one_week
.
isoformat
()))
assert
response
.
status_code
==
200
assert
len
(
response
.
json
())
==
6
or
7
# I’m not sure why, but this changes around midnight.
for
entry
in
response
.
json
():
assert_entry
(
entry
,
show
)
def
test_playout_include_virtual
(
def
test_playout_include_virtual
(
admin_api_client
,
admin_api_client
,
api_client
,
api_client
,
...
@@ -72,3 +94,35 @@ def test_playout_include_virtual(
...
@@ -72,3 +94,35 @@ def test_playout_include_virtual(
assert
virtual_entry1
[
"
end
"
]
==
entry
[
"
start
"
]
assert
virtual_entry1
[
"
end
"
]
==
entry
[
"
start
"
]
assert
entry
[
"
end
"
]
==
virtual_entry2
[
"
start
"
]
assert
entry
[
"
end
"
]
==
virtual_entry2
[
"
start
"
]
def
test_playout_one_week_include_virtual
(
admin_api_client
,
api_client
,
daily_rrule
,
show
,
fallback_show
,
radio_settings
,
):
create_daily_schedule
(
admin_api_client
,
daily_rrule
,
show
)
now
=
datetime
.
now
()
in_one_week
=
now
+
timedelta
(
days
=
7
)
response
=
api_client
.
get
(
url
(
include_virtual
=
True
,
start
=
now
.
isoformat
(),
end
=
in_one_week
.
isoformat
())
)
assert
response
.
status_code
==
200
assert
len
(
response
.
json
())
==
13
or
15
# I’m not sure why, but this changes around midnight.
entries
=
response
.
json
()
for
virtual_entry
in
entries
[
0
::
2
]:
assert_virtual_entry
(
virtual_entry
,
fallback_show
)
for
entry
in
entries
[
1
::
2
]:
assert_entry
(
entry
,
show
)
for
entry1
,
entry2
in
pairwise
(
entries
):
assert
entry1
[
"
end
"
]
==
entry2
[
"
start
"
]
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