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
4939682d
Commit
4939682d
authored
Mar 15, 2018
by
asadazam93
Committed by
AsadAzam
Mar 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix removing staff on publish
parent
22790419
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
course_discovery/apps/publisher/api/v1/tests/test_views.py
+27
-0
course_discovery/apps/publisher/api/v1/views.py
+1
-0
No files found.
course_discovery/apps/publisher/api/v1/tests/test_views.py
View file @
4939682d
...
...
@@ -235,6 +235,33 @@ class CourseRunViewSetTests(APITestCase):
course_run
=
discovery_course_run
)
@responses.activate
@mock.patch.object
(
Partner
,
'access_token'
,
return_value
=
'JWT fake'
)
def
test_publish_with_staff_removed
(
self
,
mock_access_token
):
"""
Test that the publish button adds and removes staff from discovery_course_run
"""
publisher_course_run
=
self
.
_create_course_run_for_publication
()
partner
=
publisher_course_run
.
course
.
organizations
.
first
()
.
partner
self
.
_set_test_client_domain_and_login
(
partner
)
self
.
_mock_studio_api_success
(
publisher_course_run
)
self
.
_mock_ecommerce_api
(
publisher_course_run
)
publish_url
=
reverse
(
'publisher:api:v1:course_run-publish'
,
kwargs
=
{
'pk'
:
publisher_course_run
.
pk
})
response
=
self
.
client
.
post
(
publish_url
,
{})
assert
response
.
status_code
==
200
discovery_course_run
=
CourseRun
.
objects
.
get
(
key
=
publisher_course_run
.
lms_course_id
)
assert
discovery_course_run
.
staff
.
all
()
.
count
()
==
2
publisher_course_run
.
staff
.
clear
()
publisher_course_run
.
staff
=
PersonFactory
.
create_batch
(
1
)
response
=
self
.
client
.
post
(
publish_url
,
{})
assert
response
.
status_code
==
200
discovery_course_run
=
CourseRun
.
objects
.
get
(
key
=
publisher_course_run
.
lms_course_id
)
assert
discovery_course_run
.
staff
.
all
()
.
count
()
==
1
def
test_publish_missing_course_run
(
self
):
self
.
client
.
force_login
(
StaffUserFactory
())
url
=
reverse
(
'publisher:api:v1:course_run-publish'
,
kwargs
=
{
'pk'
:
1
})
...
...
course_discovery/apps/publisher/api/v1/views.py
View file @
4939682d
...
...
@@ -154,6 +154,7 @@ class CourseRunViewSet(viewsets.GenericViewSet):
defaults
=
defaults
)
discovery_course_run
.
transcript_languages
.
add
(
*
course_run
.
transcript_languages
.
all
())
discovery_course_run
.
staff
.
clear
()
discovery_course_run
.
staff
.
add
(
*
course_run
.
staff
.
all
())
for
entitlement
in
publisher_course
.
entitlements
.
all
():
...
...
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