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
7360a79d
Commit
7360a79d
authored
Sep 21, 2017
by
Simon Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A new course_run save will create a new node on marketing site
LEARNER-2461
parent
d5622d99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
course_discovery/apps/course_metadata/publishers.py
+9
-0
course_discovery/apps/course_metadata/tests/test_publishers.py
+10
-4
No files found.
course_discovery/apps/course_metadata/publishers.py
View file @
7360a79d
...
@@ -201,6 +201,11 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
...
@@ -201,6 +201,11 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
node_data
=
self
.
serialize_obj
(
obj
)
node_data
=
self
.
serialize_obj
(
obj
)
self
.
edit_node
(
node_id
,
node_data
)
self
.
edit_node
(
node_id
,
node_data
)
elif
not
previous_obj
:
# This is a brand new course_run object
# let's create it on the marketing site
node_data
=
self
.
serialize_obj
(
obj
)
self
.
create_node
(
node_data
)
def
serialize_obj
(
self
,
obj
):
def
serialize_obj
(
self
,
obj
):
"""
"""
...
@@ -217,6 +222,10 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
...
@@ -217,6 +222,10 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
return
{
return
{
**
data
,
**
data
,
'status'
:
1
if
obj
.
status
==
CourseRunStatus
.
Published
else
0
,
'status'
:
1
if
obj
.
status
==
CourseRunStatus
.
Published
else
0
,
'field_course_uuid'
:
str
(
obj
.
uuid
),
'title'
:
obj
.
title
,
'field_course_id'
:
obj
.
key
,
'type'
:
'course'
,
}
}
...
...
course_discovery/apps/course_metadata/tests/test_publishers.py
View file @
7360a79d
...
@@ -199,16 +199,19 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
...
@@ -199,16 +199,19 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
self
.
obj
=
CourseRunFactory
()
self
.
obj
=
CourseRunFactory
()
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'serialize_obj'
,
return_value
=
'data'
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'create_node'
)
def
test_publish_obj_create
(
self
,
mock_create_node
,
*
args
):
# pylint: disable=unused-argument
self
.
publisher
.
publish_obj
(
self
.
obj
)
mock_create_node
.
assert_called_with
(
'data'
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'node_id'
,
return_value
=
'node_id'
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'node_id'
,
return_value
=
'node_id'
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'serialize_obj'
,
return_value
=
'data'
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'serialize_obj'
,
return_value
=
'data'
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'edit_node'
,
return_value
=
None
)
@mock.patch.object
(
CourseRunMarketingSitePublisher
,
'edit_node'
,
return_value
=
None
)
def
test_publish_obj
(
self
,
mock_edit_node
,
*
args
):
# pylint: disable=unused-argument
def
test_publish_obj
_edit
(
self
,
mock_edit_node
,
*
args
):
# pylint: disable=unused-argument
"""
"""
Verify that the publisher attempts to publish when course run status changes.
Verify that the publisher attempts to publish when course run status changes.
"""
"""
# No previous object. No editing should occur.
self
.
publisher
.
publish_obj
(
self
.
obj
)
assert
not
mock_edit_node
.
called
# A previous object is provided, but the status hasn't changed.
# A previous object is provided, but the status hasn't changed.
# No editing should occur.
# No editing should occur.
...
@@ -231,8 +234,11 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
...
@@ -231,8 +234,11 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
actual
=
self
.
publisher
.
serialize_obj
(
self
.
obj
)
actual
=
self
.
publisher
.
serialize_obj
(
self
.
obj
)
expected
=
{
expected
=
{
'field_course_id'
:
self
.
obj
.
key
,
'field_course_id'
:
self
.
obj
.
key
,
'field_course_uuid'
:
str
(
self
.
obj
.
uuid
),
'title'
:
self
.
obj
.
title
,
'author'
:
{
'id'
:
self
.
user_id
},
'author'
:
{
'id'
:
self
.
user_id
},
'status'
:
1
,
'status'
:
1
,
'type'
:
'course'
,
}
}
assert
actual
==
expected
assert
actual
==
expected
...
...
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