Commit 5493dd04 by Simon Chen

Stop updating title of the course based on the data from Studio

EDUCATOR-1818
parent ddee6598
...@@ -112,11 +112,13 @@ class CoursesApiDataLoader(AbstractDataLoader): ...@@ -112,11 +112,13 @@ class CoursesApiDataLoader(AbstractDataLoader):
try: try:
body = self.clean_strings(body) body = self.clean_strings(body)
course_run = self.get_course_run(body) course_run = self.get_course_run(body)
if course_run: if course_run:
self.update_course_run(course_run, body) self.update_course_run(course_run, body)
course = getattr(course_run, 'canonical_for_course', False) course = getattr(course_run, 'canonical_for_course', False)
if course: if course and not self.partner.has_marketing_site:
# If the partner have marketing site,
# we should only update the course information from the marketing site.
# Therefore, we don't need to do the statements below
course = self.update_course(course, body) course = self.update_course(course, body)
logger.info('Processed course with key [%s].', course.key) logger.info('Processed course with key [%s].', course.key)
else: else:
......
...@@ -372,7 +372,11 @@ class CourseMarketingSiteDataLoader(AbstractMarketingSiteDataLoader): ...@@ -372,7 +372,11 @@ class CourseMarketingSiteDataLoader(AbstractMarketingSiteDataLoader):
course = self.update_course(course_run.course, data) course = self.update_course(course_run.course, data)
self.set_subjects(course, data) self.set_subjects(course, data)
self.set_authoring_organizations(course, data) self.set_authoring_organizations(course, data)
logger.info('Processed course with key [%s].', course.key) logger.info(
'Processed course with key [%s] based on the data from courserun [%s]',
course.key,
course_run.key
)
except AttributeError: except AttributeError:
pass pass
else: else:
......
...@@ -251,7 +251,8 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas ...@@ -251,7 +251,8 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas
mock_logger.exception.assert_called_with(msg) mock_logger.exception.assert_called_with(msg)
@responses.activate @responses.activate
def test_ingest_canonical(self): @ddt.data(True, False)
def test_ingest_canonical(self, partner_has_marketing_site):
""" Verify the method ingests data from the Courses API. """ """ Verify the method ingests data from the Courses API. """
self.assertEqual(Course.objects.count(), 0) self.assertEqual(Course.objects.count(), 0)
self.assertEqual(CourseRun.objects.count(), 0) self.assertEqual(CourseRun.objects.count(), 0)
...@@ -261,6 +262,11 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas ...@@ -261,6 +262,11 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas
mock_data.COURSES_API_BODY_SECOND, mock_data.COURSES_API_BODY_SECOND,
mock_data.COURSES_API_BODY_UPDATED, mock_data.COURSES_API_BODY_UPDATED,
]) ])
if not partner_has_marketing_site:
self.partner.marketing_site_url_root = None
self.partner.save() # pylint: disable=no-member
self.loader.ingest() self.loader.ingest()
# Verify the CourseRun was created correctly by no errors raised # Verify the CourseRun was created correctly by no errors raised
...@@ -278,8 +284,12 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas ...@@ -278,8 +284,12 @@ class CoursesApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestCas
# Verify second course not used to update course # Verify second course not used to update course
self.assertNotEqual(mock_data.COURSES_API_BODY_SECOND['name'], course.title) self.assertNotEqual(mock_data.COURSES_API_BODY_SECOND['name'], course.title)
# Verify udpated canonical course used to update course if partner_has_marketing_site:
self.assertEqual(mock_data.COURSES_API_BODY_UPDATED['name'], course.title) # Verify the course remains unchanged by api update if we have marketing site
self.assertEqual(mock_data.COURSES_API_BODY_ORIGINAL['name'], course.title)
else:
# Verify updated canonical course used to update course
self.assertEqual(mock_data.COURSES_API_BODY_UPDATED['name'], course.title)
# Verify the updated course run updated the original course run # Verify the updated course run updated the original course run
self.assertEqual(mock_data.COURSES_API_BODY_UPDATED['hidden'], course_run_orig.hidden) self.assertEqual(mock_data.COURSES_API_BODY_UPDATED['hidden'], course_run_orig.hidden)
...@@ -466,7 +476,6 @@ class EcommerceApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestC ...@@ -466,7 +476,6 @@ class EcommerceApiDataLoaderTests(ApiClientTestMixin, DataLoaderTestMixin, TestC
loaded_seat_data = courses_api_data[:-2] loaded_seat_data = courses_api_data[:-2]
products_api_data = self.mock_products_api() products_api_data = self.mock_products_api()
self.assertEqual(CourseRun.objects.count(), len(loaded_course_run_data)) self.assertEqual(CourseRun.objects.count(), len(loaded_course_run_data))
# Verify a seat exists on all courses already # Verify a seat exists on all courses already
......
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