Skip to content

Commit

Permalink
fix: forced assignment redemption assigns course run key
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Oct 3, 2024
1 parent 2bce5b6 commit ad07969
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions enterprise_access/apps/subsidy_access_policy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,19 +1744,19 @@ def create_assignment(self):
before redemption can occur.
"""
assignment_configuration = self.subsidy_access_policy.assignment_configuration
# Ensure that the requested content key is available for the related customer.
content_metadata = get_and_cache_content_metadata(
assignment_configuration.enterprise_customer_uuid,
self.course_run_key,
)
content_key = content_metadata.get('content_key')
user_record = User.objects.filter(lms_user_id=self.lms_user_id).first()
if not user_record:
raise Exception(f'No email could be found for lms_user_id {self.lms_user_id}')

return assignments_api.allocate_assignments(
assignment_configuration,
[user_record.email],
content_key,
self.course_run_key,
self.content_price_cents,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,6 @@ def test_force_redemption_with_assignment_happy_path(self, mock_pending_learner_
)

assignment = LearnerContentAssignment.objects.filter(lms_user_id=user.lms_user_id).first()
self.assertEqual(assignment.content_key, self.course_run_key)
mock_send_email.delay.assert_called_once_with(assignment.uuid)
mock_pending_learner_task.delay.assert_called_once_with(assignment.uuid)

0 comments on commit ad07969

Please sign in to comment.