From 21ee16c41cedbd2a334b809a15b040fc7e4d1567 Mon Sep 17 00:00:00 2001 From: ansabgillani Date: Wed, 21 Dec 2022 23:40:49 +0500 Subject: [PATCH] refactor: refactoring bootcamp contentful code for consistency --- .../apps/course_metadata/contentful_utils.py | 42 +++-- .../tests/contentful_bootcamp_mock_data.py | 157 ----------------- .../contentful_utils/contentful_mock_data.py | 159 +++++++++++++++++- .../tests/test_contentful_utils.py | 77 +++++++-- 4 files changed, 241 insertions(+), 194 deletions(-) delete mode 100644 course_discovery/apps/course_metadata/tests/contentful_bootcamp_mock_data.py diff --git a/course_discovery/apps/course_metadata/contentful_utils.py b/course_discovery/apps/course_metadata/contentful_utils.py index e387764feb..6052f33c3a 100644 --- a/course_discovery/apps/course_metadata/contentful_utils.py +++ b/course_discovery/apps/course_metadata/contentful_utils.py @@ -192,9 +192,9 @@ def get_about_the_program_module(about_the_program_module): about_program_checkmarked_items.append(rich_text_to_plain_text(checkmarked_item.description)) return { - 'about_program_heading': about_program_heading, - 'about_program_content': about_program_content, - 'about_program_checkmarked_items': about_program_checkmarked_items + 'heading': about_program_heading, + 'content': about_program_content, + 'checkmarked_items': about_program_checkmarked_items } @@ -206,8 +206,8 @@ def get_blurb_module(blurb_module): blurb_1_body = rich_text_to_plain_text(blurb_module.blurb_body) return { - 'blurb_1_heading': blurb_1_heading, - 'blurb_1_body': blurb_1_body + 'heading': blurb_1_heading, + 'body': blurb_1_body } @@ -218,7 +218,7 @@ def get_bootcamp_curriculum_module(bootcamp_curriculum_module): bootcamp_curriculum_heading = rich_text_to_plain_text(bootcamp_curriculum_module.subheading) bootcamp_curriculum_faqs = get_faq_module(bootcamp_curriculum_module.items) - return {'bootcamp_curriculum_heading': bootcamp_curriculum_heading}, bootcamp_curriculum_faqs + return {'heading': bootcamp_curriculum_heading}, bootcamp_curriculum_faqs def get_faq_module(faq_module): @@ -244,8 +244,8 @@ def get_partnership_module(partnership_module): partnership_body_text = rich_text_to_plain_text(partnership_module.body_text) return { - 'partnership_heading_text': partnership_heading_text, - 'partnership_body_text': partnership_body_text + 'heading_text': partnership_heading_text, + 'body_text': partnership_body_text } @@ -309,15 +309,21 @@ def fetch_and_transform_bootcamp_contentful_data(): about_the_program = get_about_the_program_module( bootcamp_entry.modules[module_list.index('aboutTheProgramModule')] ) - transformed_bootcamp_data[product_uuid].update(about_the_program) + transformed_bootcamp_data[product_uuid].update( + {'about_the_program': about_the_program} + ) if 'blurbModule' in module_list: blurb_indexes = [i for i, x in enumerate(module_list) if x == 'blurbModule'] blurb_1 = get_blurb_module(bootcamp_entry.modules[blurb_indexes[0]]) - transformed_bootcamp_data[product_uuid].update(blurb_1) + transformed_bootcamp_data[product_uuid].update( + {'blurb_1': blurb_1} + ) if len(blurb_indexes) == 2: blurb_2 = get_blurb_module(bootcamp_entry.modules[blurb_indexes[1]]) - transformed_bootcamp_data[product_uuid].update(blurb_2) + transformed_bootcamp_data[product_uuid].update( + {'blurb_2': blurb_2} + ) faq_items = [] if 'bootCampCurriculumModule' in module_list: @@ -325,16 +331,22 @@ def fetch_and_transform_bootcamp_contentful_data(): bootcamp_entry.modules[module_list.index('bootCampCurriculumModule')] ) faq_items += bootcamp_curriculum_faqs - transformed_bootcamp_data[product_uuid].update(bootcamp_curriculum_module) + transformed_bootcamp_data[product_uuid].update( + {'bootcamp_curriculum': bootcamp_curriculum_module} + ) if 'partnershipModule' in module_list: partnership_module = get_partnership_module(bootcamp_entry.modules[module_list.index('partnershipModule')]) - transformed_bootcamp_data[product_uuid].update(partnership_module) + transformed_bootcamp_data[product_uuid].update( + {'partnerships': partnership_module} + ) if 'faqModule' in module_list: faq_module = get_faq_module(bootcamp_entry.modules[module_list.index('faqModule')].faqs) faq_items += faq_module - transformed_bootcamp_data[product_uuid].update({'faq_items': faq_items}) + transformed_bootcamp_data[product_uuid].update( + {'faq_items': faq_items} + ) return transformed_bootcamp_data @@ -375,7 +387,7 @@ def fetch_and_transform_degree_contentful_data(): if 'aboutTheProgramModule' in module_list: about_the_program = get_about_the_program_module( degree_entry.modules[module_list.index('aboutTheProgramModule')]) - transformed_degree_data[product_uuid].update(about_the_program) + transformed_degree_data[product_uuid].update({'about_the_program': about_the_program}) if 'featuredProductsModule' in module_list: featured_products = get_featured_products_module( diff --git a/course_discovery/apps/course_metadata/tests/contentful_bootcamp_mock_data.py b/course_discovery/apps/course_metadata/tests/contentful_bootcamp_mock_data.py deleted file mode 100644 index a3ae3d6ccc..0000000000 --- a/course_discovery/apps/course_metadata/tests/contentful_bootcamp_mock_data.py +++ /dev/null @@ -1,157 +0,0 @@ -# pylint: disable=line-too-long -""" -Mock data for testing purposes of Contentful Bootcamp Data transformation utils. -""" -import random -import string - -from contentful import Entry - - -def create_contentful_entry(entry_name, fields): - return Entry({ - 'metadata': {'tags': []}, - 'sys': { - 'space': {'sys': {'type': 'Link', 'linkType': 'Space', 'id': 'test_space_id'}}, - 'id': ''.join(random.choices(string.ascii_letters + string.digits, k=22)), - 'type': 'Entry', - 'createdAt': '2022-12-05T21:20:18.606Z', - 'updatedAt': '2022-12-05T21:20:18.606Z', - 'environment': {'sys': {'id': 'master', 'type': 'Link', 'linkType': 'Environment'}}, - 'revision': 1, - 'contentType': { - 'sys': {'type': 'Link', 'linkType': 'ContentType', 'id': entry_name}}, - 'locale': 'en-US' - }, - 'fields': fields - }) - - -seo_entry = create_contentful_entry('seo', { - 'pageTitle': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'pageDescription': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'languageCode': 'en' -}) - -hero_entry = create_contentful_entry('hero', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'subheading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'textList': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'unordered-list', 'data': {}, 'content': [{'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}]}]}, -}) - -about_the_program_entry = create_contentful_entry('aboutTheProgramModule', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'content': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, - 'checkmarkedItems': create_contentful_entry('textListModule', { - 'title': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'theme': 'background-white', - 'textListItems': [create_contentful_entry('textListItem', { - 'header': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'description': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]} - })] - }), -}) - -blurb1_entry = create_contentful_entry('blurbModule', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'blurbHeading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'blurbBody': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'nodeType': 'embedded-entry-inline', 'content': []}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'nodeType': 'embedded-entry-inline', 'content': []}]}, {'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]} -}) - -bootcamp_curriculum_entry = create_contentful_entry('bootCampCurriculumModule', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'subheading': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, - 'items': [create_contentful_entry('faq', { - 'name': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'answerRichText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}]}, {'nodeType': 'unordered-list', 'data': {}, 'content': [{'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}]}]} - })] -}) - -partnership_entry = create_contentful_entry('partnershipModule', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'headingText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, - 'bodyText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ', ', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'ipsum', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ', or ', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'dolor', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, -}) - -blurb2_entry = create_contentful_entry('blurbModule', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'blurbHeading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'blurbBody': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]} -}) - -faq_entry = create_contentful_entry('faqModule', { - 'name': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'faqs': [ - create_contentful_entry('faq', { - 'name': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'answerRichText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}]}, {'nodeType': 'unordered-list', 'data': {}, 'content': [{'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}]}]} - }) - ] -}) - -mock_contentful_bootcamp_entry = create_contentful_entry('bootCampPage', { - 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'uuid': 'test-uuid', - 'seo': seo_entry, - 'hero': hero_entry, - 'modules': [ - about_the_program_entry, - blurb1_entry, - bootcamp_curriculum_entry, - partnership_entry, - blurb2_entry, - faq_entry, - ] -}) - -bootcamp_transformed_data = { - 'test-uuid': { - 'page_title': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'subheading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'hero_text_list': 'Lorem ipsum: dolor sit amet, consectetur adipiscing elitLorem ipsum: dolor sit amet,' - ' consectetur adipiscing elitLorem ipsum: dolor sit amet, consectetur adipiscing elitLorem' - ' ipsum: dolor sit amet, consectetur adipiscing elit', - 'about_program_heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'about_program_content': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'about_program_checkmarked_items': ['Lorem ipsum: dolor sit amet, consectetur adipiscing elit'], - 'blurb_1_heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'blurb_1_body': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur' - ' adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit', - 'bootcamp_curriculum_heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit ' - 'amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur ' - 'adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem ' - 'ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet,' - ' consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur ' - 'adipiscing elit', - 'partnership_heading_text': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'partnership_body_text': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem, ipsum, or dolorLorem ' - 'ipsum dolor sit amet, consectetur adipiscing elit', - 'faq_items': [ - { - 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'answer': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet,' - ' consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem' - ' ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, ' - 'consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' - }, - { - 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'answer': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, ' - 'consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem' - ' ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur' - ' adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' - } - ] - } -} - - -class MockContentBootcampResponse: - """ - Mock response received from Contentful for bootcamp - """ - items = [mock_contentful_bootcamp_entry] - total = 15 diff --git a/course_discovery/apps/course_metadata/tests/contentful_utils/contentful_mock_data.py b/course_discovery/apps/course_metadata/tests/contentful_utils/contentful_mock_data.py index 7c4f378a11..0f664c9c1b 100644 --- a/course_discovery/apps/course_metadata/tests/contentful_utils/contentful_mock_data.py +++ b/course_discovery/apps/course_metadata/tests/contentful_utils/contentful_mock_data.py @@ -104,11 +104,11 @@ def __init__(self): 'test-uuid': { 'page_title': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'subheading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'about_program_heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'about_program_content': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', - 'about_program_checkmarked_items': [ - 'Lorem ipsum: dolor sit amet, consectetur adipiscing elit' - ], + 'about_the_program': { + 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'content': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'checkmarked_items': ['Lorem ipsum: dolor sit amet, consectetur adipiscing elit'] + }, 'faq_items': [ { 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', @@ -134,3 +134,152 @@ def __init__(self): } } } + + +def create_bootcamp_mock_response_data(): + + seo_entry = create_contentful_entry('seo', { + 'pageTitle': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'pageDescription': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'languageCode': 'en' + }) + + hero_entry = create_contentful_entry('hero', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'subheading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'textList': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'unordered-list', 'data': {}, 'content': [{'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}]}]}, + }) + + about_the_program_entry = create_contentful_entry('aboutTheProgramModule', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'content': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, + 'checkmarkedItems': create_contentful_entry('textListModule', { + 'title': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'theme': 'background-white', + 'textListItems': [create_contentful_entry('textListItem', { + 'header': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'description': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum:', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ' dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]} + })] + }), + }) + + blurb1_entry = create_contentful_entry('blurbModule', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'blurbHeading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'blurbBody': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'nodeType': 'embedded-entry-inline', 'content': []}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'nodeType': 'embedded-entry-inline', 'content': []}]}, {'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]} + }) + + bootcamp_curriculum_entry = create_contentful_entry('bootCampCurriculumModule', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'subheading': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, + 'items': [create_contentful_entry('faq', { + 'name': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'answerRichText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}]}, {'nodeType': 'unordered-list', 'data': {}, 'content': [{'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}]}]} + })] + }) + + partnership_entry = create_contentful_entry('partnershipModule', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'headingText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, + 'bodyText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'Lorem', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ', ', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'ipsum', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': ', or ', 'nodeType': 'text', 'marks': [], 'data': {}}, {'value': 'dolor', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}, {'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, + }) + + blurb2_entry = create_contentful_entry('blurbModule', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'blurbHeading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'blurbBody': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'heading-3', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]} + }) + + faq_entry = create_contentful_entry('faqModule', { + 'name': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'faqs': [ + create_contentful_entry('faq', { + 'name': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'answerRichText': {'nodeType': 'document', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}, {'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {}}]}, {'nodeType': 'unordered-list', 'data': {}, 'content': [{'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}, {'nodeType': 'list-item', 'data': {}, 'content': [{'nodeType': 'paragraph', 'data': {}, 'content': [{'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'nodeType': 'text', 'marks': [], 'data': {}}]}]}]}]} + }) + ] + }) + + return create_contentful_entry('bootCampPage', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'uuid': 'test-uuid', + 'seo': seo_entry, + 'hero': hero_entry, + 'modules': [ + about_the_program_entry, + blurb1_entry, + bootcamp_curriculum_entry, + partnership_entry, + blurb2_entry, + faq_entry, + ] + }) + + +class MockContentfulBootcampResponse: + """ + Mock response received from Contentful for bootcamp + """ + total = 15 + items = [create_bootcamp_mock_response_data()] + + def __init__(self): + self.mock_contentful_bootcamp_entry = self.items[0] + self.bootcamp_transformed_data = { + 'test-uuid': { + 'page_title': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'subheading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'hero_text_list': 'Lorem ipsum: dolor sit amet, consectetur adipiscing elitLorem ipsum: dolor sit amet,' + ' consectetur adipiscing elitLorem ipsum: dolor sit amet, consectetur adipiscing elitLorem' + ' ipsum: dolor sit amet, consectetur adipiscing elit', + 'about_the_program': { + 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'content': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'checkmarked_items': ['Lorem ipsum: dolor sit amet, consectetur adipiscing elit'] + }, + 'blurb_1': { + 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'body': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet,' + ' consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' + 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet,' + ' consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + }, + "blurb_2": { + "heading": "Lorem ipsum dolor sit amet, consectetur adipiscing elit", + "body": 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur' + ' adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' + }, + 'bootcamp_curriculum': { + 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit ' + 'amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur ' + 'adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem ' + 'ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet,' + ' consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' + }, + 'partnerships': { + 'heading_text': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'body_text': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem, ipsum, or dolorLorem ' + 'ipsum dolor sit amet, consectetur adipiscing elit', + }, + 'faq_items': [ + { + 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'answer': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet,' + ' consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem' + ' ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, ' + 'consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' + }, + { + 'question': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'answer': 'Lorem ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, ' + 'consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem' + ' ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur' + ' adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elit' + } + ] + } + } diff --git a/course_discovery/apps/course_metadata/tests/test_contentful_utils.py b/course_discovery/apps/course_metadata/tests/test_contentful_utils.py index 9d4f02a976..9575165b2a 100644 --- a/course_discovery/apps/course_metadata/tests/test_contentful_utils.py +++ b/course_discovery/apps/course_metadata/tests/test_contentful_utils.py @@ -14,11 +14,8 @@ get_aggregated_data_from_contentful_data, get_contentful_cache_key, get_data_from_contentful, rich_text_to_plain_text ) -from course_discovery.apps.course_metadata.tests.contentful_bootcamp_mock_data import ( - MockContentBootcampResponse, about_the_program_entry, bootcamp_transformed_data, mock_contentful_bootcamp_entry -) from course_discovery.apps.course_metadata.tests.contentful_utils.contentful_mock_data import ( - MockContenfulDegreeResponse + MockContenfulDegreeResponse, MockContentfulBootcampResponse, create_contentful_entry ) LOGGER_NAME = 'course_discovery.apps.course_metadata.contentful_utils' @@ -35,26 +32,32 @@ def test_get_data_from_contentful(self, mock_client): """ Test get_data_from_contentful utility with mock data. """ - mock_client.return_value.entries.return_value = MockContentBootcampResponse - contentful_data = get_data_from_contentful(settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) + mock_response = MockContentfulBootcampResponse() + mock_client.return_value.entries.return_value = MockContentfulBootcampResponse + contentful_data = get_data_from_contentful( + settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) + assert len(contentful_data) == 2 - assert contentful_data[0] == mock_contentful_bootcamp_entry - self.assertDictEqual(contentful_data[0].raw, mock_contentful_bootcamp_entry.raw) + assert contentful_data[0] == mock_response.mock_contentful_bootcamp_entry + self.assertDictEqual( + contentful_data[0].raw, mock_response.mock_contentful_bootcamp_entry.raw) @mock.patch('course_discovery.apps.course_metadata.contentful_utils.Client') def test_get_cached_data_from_contentful(self, mock_client): """ Test get_data_from_contentful utility with mock data. """ - self.maxDiff = None - mock_client.return_value.entries.return_value = MockContentBootcampResponse - cache_key = get_contentful_cache_key(settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) + mock_response = MockContentfulBootcampResponse() + mock_client.return_value.entries.return_value = MockContentfulBootcampResponse + cache_key = get_contentful_cache_key( + settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) assert cache.get(cache_key) is None _ = get_data_from_contentful(settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) assert cache.get(cache_key) is not None with LogCapture(LOGGER_NAME) as log_capture: - contentful_data = get_data_from_contentful(settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) + contentful_data = get_data_from_contentful( + settings.BOOTCAMP_CONTENTFUL_CONTENT_TYPE) log_capture.check( ( @@ -65,26 +68,64 @@ def test_get_cached_data_from_contentful(self, mock_client): ) ) assert len(contentful_data) == 2 - assert contentful_data[0].uuid == mock_contentful_bootcamp_entry.uuid + assert contentful_data[0].uuid == mock_response.mock_contentful_bootcamp_entry.uuid def test_rich_text_to_plain_text(self): """ Test rich_text_to_plain_text utility which transforms rich text to plain text. """ + about_the_program_entry = create_contentful_entry('aboutTheProgramModule', { + 'internalName': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'heading': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'content': {'nodeType': 'document', 'data': {}, 'content': [ + { + 'nodeType': 'paragraph', 'data': {}, 'content': [ + { + 'value': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'nodeType': 'text', 'marks': [], 'data': {} + } + ] + } + ]}, + 'checkmarkedItems': create_contentful_entry('textListModule', { + 'title': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'theme': 'background-white', + 'textListItems': [create_contentful_entry('textListItem', { + 'header': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', + 'description': {'nodeType': 'document', 'data': {}, 'content': [ + { + 'nodeType': 'paragraph', 'data': {}, 'content': [ + { + 'value': 'Lorem ipsum:', + 'nodeType': 'text', 'marks': [{'type': 'bold'}], 'data': {} + }, + { + 'value': ' dolor sit amet, consectetur adipiscing elit', + 'nodeType': 'text', 'marks': [], 'data': {} + } + ] + } + ]} + })] + }), + }) plain_text = rich_text_to_plain_text(about_the_program_entry.content) expected_text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' assert plain_text == expected_text @mock.patch('course_discovery.apps.course_metadata.contentful_utils.get_data_from_contentful', - return_value=[mock_contentful_bootcamp_entry]) + return_value=[MockContentfulBootcampResponse().mock_contentful_bootcamp_entry]) def test_transform_bootcamp_contentful_data(self, *args): """ Test transform_bootcamp_contentful_data given a mocked entry from contentful. """ + mock_bootcamp_response = MockContentfulBootcampResponse() transformed_data = fetch_and_transform_bootcamp_contentful_data() - self.assertDictEqual(transformed_data, bootcamp_transformed_data) + self.assertDictEqual( + transformed_data, mock_bootcamp_response.bootcamp_transformed_data) def test_get_aggregated_data_from_contentful_data(self): + mock_bootcamp_response = MockContentfulBootcampResponse() expected_data = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, ' \ 'consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur adipiscing elitLorem ' \ 'ipsum dolor sit amet, consectetur adipiscing elitLorem ipsum dolor sit amet, consectetur ' \ @@ -99,8 +140,10 @@ def test_get_aggregated_data_from_contentful_data(self): 'consectetur adipiscing elit' assert get_aggregated_data_from_contentful_data({}, 'uuid_123') is None - assert get_aggregated_data_from_contentful_data(bootcamp_transformed_data, 'no_uuid') is None - assert get_aggregated_data_from_contentful_data(bootcamp_transformed_data, 'test-uuid') == expected_data + assert get_aggregated_data_from_contentful_data( + mock_bootcamp_response.bootcamp_transformed_data, 'no_uuid') is None + assert get_aggregated_data_from_contentful_data( + mock_bootcamp_response.bootcamp_transformed_data, 'test-uuid') == expected_data @mock.patch('course_discovery.apps.course_metadata.contentful_utils.get_data_from_contentful', return_value=[MockContenfulDegreeResponse().mock_contentful_degree_entry])