Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: strip emeritus course title during sync #3317

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion courses/sync_external_courses/emeritus_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class EmeritusCourse:
"""

def __init__(self, emeritus_course_json):
self.course_title = emeritus_course_json.get("program_name", None)
program_name = emeritus_course_json.get("program_name", None)
self.course_title = program_name.strip() if program_name else None
self.course_code = emeritus_course_json.get("course_code")

# Emeritus course code format is `MO-<COURSE_TAG>`, where course tag can contain `.`,
Expand Down
8 changes: 4 additions & 4 deletions courses/sync_external_courses/emeritus_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,21 +744,21 @@ def test_save_page_revision(is_draft_page, has_unpublished_changes):
("title", "course_code", "course_run_code", "is_valid"),
[
(
"Internet of Things (IoT): Design and Applications",
"Internet of Things (IoT): Design and Applications ",
"MO-DBIP",
"MO-DBIP.ELE-99-07#1",
True,
),
("", "MO-DBIP", "MO-DBIP.ELE-99-07#1", False),
(None, "MO-DBIP", "MO-DBIP.ELE-99-07#1", False),
(
"Internet of Things (IoT): Design and Applications",
" Internet of Things (IoT): Design and Applications ",
"",
"MO-DBIP.ELE-99-07#1",
False,
),
(
"Internet of Things (IoT): Design and Applications",
" Internet of Things (IoT): Design and Applications",
None,
"MO-DBIP.ELE-99-07#1",
False,
Expand All @@ -776,7 +776,7 @@ def test_emeritus_course_validate_required_fields(
Tests that EmeritusCourse.validate_required_fields validates required fields.
"""
emeritus_course = EmeritusCourse(emeritus_course_data)
emeritus_course.course_title = title
emeritus_course.course_title = title.strip() if title else title
emeritus_course.course_code = course_code
emeritus_course.course_run_code = course_run_code
assert emeritus_course.validate_required_fields() == is_valid
Expand Down
Loading