Commit f64e79e9 by Simon Chen

Stop syncing course UUID with Drupal page on discovery object edit

EDUCATOR-1957
parent 053467c6
......@@ -346,6 +346,9 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
self.edit_node(node_id, node_data)
elif waffle.switch_is_active('auto_course_about_page_creation'):
node_data = self.serialize_obj(obj)
# We also want to push the course uuid during creation so the node is sourcing
# course about data from discovery
node_data.update({'field_course_uuid': str(obj.uuid)})
node_id = self.create_node(node_data)
logger.info('Created new marketing site node [%s] for course run [%s].', node_id, obj.key)
self.update_node_alias(obj, node_id, previous_obj)
......@@ -365,7 +368,6 @@ class CourseRunMarketingSitePublisher(BaseMarketingSitePublisher):
return {
**data,
'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',
......
......@@ -214,7 +214,7 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
mock_node_id.assert_called_with(self.obj)
assert not mock_create_node.called
@mock.patch.object(CourseRunMarketingSitePublisher, 'serialize_obj', return_value='data')
@mock.patch.object(CourseRunMarketingSitePublisher, 'serialize_obj', return_value={'data': 'test'})
@mock.patch.object(CourseRunMarketingSitePublisher, 'node_id', return_value=None)
@mock.patch.object(CourseRunMarketingSitePublisher, 'create_node', return_value='node_id')
@mock.patch.object(CourseRunMarketingSitePublisher, 'update_node_alias')
......@@ -226,11 +226,11 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
): # pylint: disable=unused-argument
toggle_switch('auto_course_about_page_creation', True)
self.publisher.publish_obj(self.obj)
mock_create_node.assert_called_with('data')
mock_create_node.assert_called_with({'data': 'test', 'field_course_uuid': str(self.obj.uuid)})
mock_update_node_alias.assert_called_with(self.obj, 'node_id', None)
@mock.patch.object(CourseRunMarketingSitePublisher, 'node_id', return_value=None)
@mock.patch.object(CourseRunMarketingSitePublisher, 'serialize_obj', return_value='data')
@mock.patch.object(CourseRunMarketingSitePublisher, 'serialize_obj', return_value={'data': 'test'})
@mock.patch.object(CourseRunMarketingSitePublisher, 'create_node', return_value='node1')
@mock.patch.object(CourseRunMarketingSitePublisher, 'update_node_alias')
def test_publish_obj_create_if_exists_on_discovery(
......@@ -245,7 +245,7 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
self.publisher.publish_obj(self.obj, previous_obj=self.obj)
mock_node_id.assert_called_with(self.obj)
mock_serialize_obj.assert_called_with(self.obj)
mock_create_node.assert_called_with('data')
mock_create_node.assert_called_with({'data': 'test', 'field_course_uuid': str(self.obj.uuid)})
mock_update_node_alias.assert_called_with(self.obj, 'node1', self.obj)
@mock.patch.object(CourseRunMarketingSitePublisher, 'node_id', return_value='node_id')
......@@ -277,7 +277,6 @@ class CourseRunMarketingSitePublisherTests(MarketingSitePublisherTestMixin):
actual = self.publisher.serialize_obj(self.obj)
expected = {
'field_course_id': self.obj.key,
'field_course_uuid': str(self.obj.uuid),
'title': self.obj.title,
'author': {'id': self.user_id},
'status': 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment