Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
course-discovery
Commits
e634129d
Commit
e634129d
authored
Oct 18, 2016
by
mikedikan
Committed by
GitHub
Oct 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #388 from edx/mdikan/address-pr-comments-unpublished-programs
Addressing PR comments
parents
2e024585
abc9084d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
course_discovery/apps/api/v1/tests/test_views/test_course_runs.py
+29
-0
No files found.
course_discovery/apps/api/v1/tests/test_views/test_course_runs.py
View file @
e634129d
...
@@ -68,6 +68,35 @@ class CourseRunViewSetTests(SerializationMixin, ElasticsearchTestMixin, APITestC
...
@@ -68,6 +68,35 @@ class CourseRunViewSetTests(SerializationMixin, ElasticsearchTestMixin, APITestC
self
.
serialize_course_run
(
self
.
course_run
,
extra_context
=
{
'include_deleted_programs'
:
True
})
self
.
serialize_course_run
(
self
.
course_run
,
extra_context
=
{
'include_deleted_programs'
:
True
})
)
)
def
test_get_exclude_unpublished_programs
(
self
):
""" Verify the endpoint returns no associated unpublished programs """
ProgramFactory
(
courses
=
[
self
.
course_run
.
course
],
status
=
ProgramStatus
.
Unpublished
)
url
=
reverse
(
'api:v1:course_run-detail'
,
kwargs
=
{
'key'
:
self
.
course_run
.
key
})
with
self
.
assertNumQueries
(
12
):
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
.
get
(
'programs'
),
[])
def
test_get_include_unpublished_programs
(
self
):
"""
Verify the endpoint returns associated unpublished programs
with the 'include_unpublished_programs' flag set to True
"""
ProgramFactory
(
courses
=
[
self
.
course_run
.
course
],
status
=
ProgramStatus
.
Unpublished
)
url
=
reverse
(
'api:v1:course_run-detail'
,
kwargs
=
{
'key'
:
self
.
course_run
.
key
})
url
+=
'?include_unpublished_programs=1'
with
self
.
assertNumQueries
(
19
):
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
,
self
.
serialize_course_run
(
self
.
course_run
,
extra_context
=
{
'include_unpublished_programs'
:
True
})
)
def
test_list
(
self
):
def
test_list
(
self
):
""" Verify the endpoint returns a list of all catalogs. """
""" Verify the endpoint returns a list of all catalogs. """
url
=
reverse
(
'api:v1:course_run-list'
)
url
=
reverse
(
'api:v1:course_run-list'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment