Commit 2ce0d0c9 by McKenzie Welter Committed by McKenzie Welter

compare enrollment run key to program data course run list

parent 052a064e
...@@ -131,10 +131,10 @@ class ProgramCourseRunSeatsCondition(SingleItemConsumptionConditionMixin, Condit ...@@ -131,10 +131,10 @@ class ProgramCourseRunSeatsCondition(SingleItemConsumptionConditionMixin, Condit
for course in program['courses']: for course in program['courses']:
# If the user is already enrolled in a course, we do not need to check their basket for it # If the user is already enrolled in a course, we do not need to check their basket for it
if any(course['key'] in enrollment['course_details']['course_id'] and if any(enrollment['course_details']['course_id'] in [run['key'] for run in course['course_runs']] and
enrollment['mode'] in applicable_seat_types for enrollment in enrollments): enrollment['mode'] in applicable_seat_types for enrollment in enrollments):
continue continue
if any(course['uuid'] in entitlement['course_uuid'] and if any(course['uuid'] == entitlement['course_uuid'] and
entitlement['mode'] in applicable_seat_types for entitlement in entitlements): entitlement['mode'] in applicable_seat_types for entitlement in entitlements):
continue continue
......
...@@ -92,8 +92,6 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase): ...@@ -92,8 +92,6 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase):
program = self.mock_program_detail_endpoint( program = self.mock_program_detail_endpoint(
self.condition.program_uuid, self.site_configuration.discovery_api_url self.condition.program_uuid, self.site_configuration.discovery_api_url
) )
enrollments = [{'mode': 'verified', 'course_details': {'course_id': 'course-v1:test-org+course+1'}},
{'mode': 'verified', 'course_details': {'course_id': 'course-v1:test-org+course+2'}}]
# Extract one verified seat for each course # Extract one verified seat for each course
verified_seats = [] verified_seats = []
...@@ -103,8 +101,14 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase): ...@@ -103,8 +101,14 @@ class ProgramCourseRunSeatsConditionTests(ProgramTestMixin, TestCase):
if seat.attr.id_verification_required: if seat.attr.id_verification_required:
verified_seats.append(seat) verified_seats.append(seat)
# Add verified enrollments for the first two program courses to the mock user data
enrollments = [
{'mode': 'verified', 'course_details': {'course_id': program['courses'][0]['course_runs'][0]['key']}},
{'mode': 'verified', 'course_details': {'course_id': program['courses'][1]['course_runs'][0]['key']}}
]
self.mock_user_data(basket.owner.username, owned_products=enrollments) self.mock_user_data(basket.owner.username, owned_products=enrollments)
# If the user has not added all of the remaining courses in program to their basket,
# If the user has not added all of the remaining courses in the program to their basket,
# the condition should not be satisfied # the condition should not be satisfied
basket.flush() basket.flush()
for seat in verified_seats[2:len(verified_seats) - 1]: for seat in verified_seats[2:len(verified_seats) - 1]:
......
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