fix: allow for entitlement with no psuedo-sessions (#31464)

It is possible to have an entitlement with no available course runs. In
this case, the entitlement is filtered out by the view logic but the
residual, bad pesudo-session mapping can cause breaks if we don't handle
for this case.
This commit is contained in:
Nathan Sprenkle
2022-12-20 13:18:30 -05:00
committed by GitHub
parent e328b36f8e
commit 17d076e8a7
2 changed files with 14 additions and 0 deletions

View File

@@ -325,6 +325,18 @@ class TestGetCourseOverviewsForPseudoSessions(SharedModuleStoreTestCase):
# Then I should get an empty dict
self.assertDictEqual(course_overviews, {})
def test_entitlement_without_pseudo_session(self):
# Given an unfulfilled entitlement which does not have a psuedo session
pseudo_sessions = {
uuid4(): None,
}
# When I query course overviews
course_overviews = get_course_overviews_for_pseudo_sessions(pseudo_sessions)
# Then I should gracefully return none for that entitlement
self.assertDictEqual(course_overviews, {})
class TestGetEmailSettingsInfo(SharedModuleStoreTestCase):
"""Tests for get_email_settings_info"""

View File

@@ -182,6 +182,8 @@ def get_course_overviews_for_pseudo_sessions(unfulfilled_entitlement_pseudo_sess
# Get course IDs from unfulfilled entitlement pseudo sessions
for pseudo_session in unfulfilled_entitlement_pseudo_sessions.values():
if not pseudo_session:
continue
course_id = pseudo_session.get("key")
if course_id:
course_ids.append(CourseKey.from_string(course_id))