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
967e78c3
Verified
Commit
967e78c3
authored
8 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: add calendar program tests
parent
3a18517d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!52
new program endpoint
Pipeline
#8325
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_calendar_program.py
+118
-0
118 additions, 0 deletions
program/tests/test_calendar_program.py
with
118 additions
and
0 deletions
program/tests/test_calendar_program.py
0 → 100644
+
118
−
0
View file @
967e78c3
import
pytest
from
conftest
import
create_daily_schedule
pytestmark
=
pytest
.
mark
.
django_db
def
url
(
include_virtual
=
False
,
start
=
None
,
end
=
None
):
if
include_virtual
and
start
and
end
:
return
f
"
/api/v1/program/calendar/?include_virtual=true&start=
{
start
}
&end=
{
end
}
"
elif
start
and
end
:
return
f
"
/api/v1/program/calendar/?start=
{
start
}
&end=
{
end
}
"
elif
include_virtual
:
return
"
/api/v1/program/calendar/?include_virtual=true
"
else
:
return
"
/api/v1/program/calendar/
"
def
assert_episodes
(
episodes
)
->
None
:
"""
asserts the episodes are valid.
"""
assert
len
(
episodes
)
==
1
assert
episodes
[
0
][
"
id
"
]
assert
episodes
[
0
][
"
timeslotId
"
]
def
assert_program
(
program
,
show
,
fallback_show
=
None
)
->
None
:
"""
asserts the program are valid and correspond to the given show and fallback show.
"""
assert
len
(
program
)
==
1
if
fallback_show
is
None
else
3
assert
program
[
0
][
"
end
"
]
assert
program
[
0
][
"
id
"
]
assert
program
[
0
][
"
start
"
]
if
fallback_show
is
None
:
assert
program
[
0
][
"
showId
"
]
==
show
.
id
assert
program
[
0
][
"
timeslotId
"
]
else
:
assert
program
[
0
][
"
showId
"
]
==
fallback_show
.
id
assert
program
[
1
][
"
showId
"
]
==
show
.
id
assert
program
[
1
][
"
timeslotId
"
]
def
assert_shows
(
shows
,
show
,
fallback_show
=
None
)
->
None
:
"""
asserts the shows are valid correspond to the given show and fallback show.
"""
assert
len
(
shows
)
==
1
if
fallback_show
is
None
else
2
if
fallback_show
is
None
:
assert
shows
[
0
][
"
id
"
]
==
show
.
id
assert
shows
[
0
][
"
name
"
]
==
show
.
name
else
:
assert
shows
[
0
][
"
id
"
]
==
show
.
id
assert
shows
[
0
][
"
name
"
]
==
show
.
name
assert
shows
[
1
][
"
id
"
]
==
fallback_show
.
id
assert
shows
[
1
][
"
name
"
]
==
fallback_show
.
name
def
assert_timeslots
(
timeslots
,
show
)
->
None
:
"""
asserts the timeslots are valid correspond to the given show.
"""
assert
len
(
timeslots
)
==
1
assert
timeslots
[
0
][
"
id
"
]
assert
timeslots
[
0
][
"
noteId
"
]
assert
timeslots
[
0
][
"
end
"
]
assert
timeslots
[
0
][
"
start
"
]
assert
timeslots
[
0
][
"
showId
"
]
==
show
.
id
def
test_calendar
(
admin_api_client
,
api_client
,
daily_rrule
,
show
):
create_daily_schedule
(
admin_api_client
,
daily_rrule
,
show
)
response
=
api_client
.
get
(
url
())
assert
response
.
status_code
==
200
for
key
,
value
in
response
.
json
().
items
():
match
key
:
case
"
episodes
"
:
assert_episodes
(
value
)
case
"
program
"
:
assert_program
(
value
,
show
)
case
"
shows
"
:
assert_shows
(
value
,
show
)
case
"
timeslots
"
:
assert_timeslots
(
value
,
show
)
def
test_calendar_include_virtual
(
admin_api_client
,
api_client
,
daily_rrule
,
show
,
fallback_show
,
radio_settings
,
):
create_daily_schedule
(
admin_api_client
,
daily_rrule
,
show
)
response
=
api_client
.
get
(
url
(
include_virtual
=
True
))
assert
response
.
status_code
==
200
for
key
,
value
in
response
.
json
().
items
():
match
key
:
case
"
episodes
"
:
assert_episodes
(
value
)
case
"
program
"
:
print
(
value
)
assert_program
(
value
,
show
,
fallback_show
)
case
"
shows
"
:
assert_shows
(
value
,
show
,
fallback_show
)
case
"
timeslots
"
:
assert_timeslots
(
value
,
show
)
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