Skip to content

Commit dc90e03

Browse files
committed
fix: fix tests
1 parent 1d01428 commit dc90e03

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎lms/djangoapps/course_api/serializers.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ def get_overview(self, course_overview):
160160
# Note: This makes a call to the modulestore, unlike the other
161161
# fields from CourseSerializer, which get their data
162162
# from the CourseOverview object in SQL.
163-
return CourseDetails.fetch_about_attribute(course_overview.id, 'overview')
163+
overview_value = CourseDetails.fetch_about_attribute(course_overview.id, 'overview')
164+
165+
# Convert None or empty string to empty dict for consistency
166+
# empty string means no template data was found
167+
return overview_value or {}
164168

165169
def to_representation(self, instance):
166170
"""

‎lms/djangoapps/course_api/tests/test_serializers.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ def setUp(self):
159159

160160
# update the expected_data to include the 'overview' data.
161161
about_block = XBlock.load_class('about')
162-
overview_template = about_block.get_template('overview.yaml')
163-
self.expected_data['overview'] = overview_template.get('data')
162+
get_template = getattr(about_block, "get_template", None)
163+
overview_template = (
164+
get_template("overview.yaml") if callable(get_template) else {}
165+
)
166+
self.expected_data['overview'] = overview_template.get('data', {})
164167

165168
# override test case
166169
@mock.patch(

0 commit comments

Comments
 (0)