-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5707c2
commit 467ff12
Showing
2 changed files
with
32 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,6 +443,18 @@ def setUpTestData(cls): | |
spend_limit=10000 * 100, | ||
) | ||
|
||
# Mock results from the catalog content metadata API endpoint. | ||
cls.mock_catalog_result = { | ||
'count': 2, | ||
'results': [ | ||
{ | ||
'key': cls.content_key, | ||
'parent_content_key': cls.parent_content_key, | ||
'data': 'things', | ||
}, | ||
], | ||
} | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.maxDiff = None | ||
|
@@ -461,14 +473,6 @@ def setUp(self): | |
def delete_assignments(): | ||
return self.assignment_configuration.assignments.all().delete() | ||
|
||
# Mock results from the catalog content metadata API endpoint. | ||
self.mock_catalog_result = { | ||
'count': 2, | ||
'results': [ | ||
{'key': 'course+A', 'data': 'things'}, {'key': 'course+B', 'data': 'stuff'}, | ||
], | ||
} | ||
|
||
self.addCleanup(delete_assignments) | ||
|
||
@mock.patch.object( | ||
|
@@ -559,6 +563,7 @@ def test_allocate_happy_path_e2e( | |
email='[email protected]', | ||
lms_user_id=4277 | ||
) | ||
assignment_content_quantity_usd_cents = 12345 | ||
LearnerContentAssignmentFactory( | ||
assignment_configuration=self.assignment_configuration, | ||
learner_email='[email protected]', | ||
|
@@ -569,7 +574,7 @@ def test_allocate_happy_path_e2e( | |
parent_content_key=self.parent_content_key, | ||
is_assigned_course_run=True, | ||
content_title=self.content_title, | ||
content_quantity=-12345, | ||
content_quantity=-assignment_content_quantity_usd_cents, | ||
state=LearnerContentAssignmentStateChoices.EXPIRED, | ||
) | ||
|
||
|
@@ -585,7 +590,7 @@ def test_allocate_happy_path_e2e( | |
allocate_payload = { | ||
'learner_emails': ['[email protected]', '[email protected]', '[email protected]'], | ||
'content_key': self.content_key, | ||
'content_price_cents': 123.45 * 100, # policy limit is 100000.00 USD, so this should be well below limit | ||
'content_price_cents': assignment_content_quantity_usd_cents, # this should be well below limit | ||
} | ||
|
||
response = self.client.post(allocate_url, data=allocate_payload) | ||
|
@@ -595,7 +600,7 @@ def test_allocate_happy_path_e2e( | |
for assignment in self.assignment_configuration.assignments.filter( | ||
state=LearnerContentAssignmentStateChoices.ALLOCATED, | ||
content_key=self.content_key, | ||
content_quantity=-123.45 * 100, | ||
content_quantity=-assignment_content_quantity_usd_cents | ||
) | ||
} | ||
self.assertEqual(3, len(allocation_records_by_email)) | ||
|
@@ -611,7 +616,7 @@ def test_allocate_happy_path_e2e( | |
'parent_content_key': self.parent_content_key, | ||
'is_assigned_course_run': True, | ||
'content_title': self.content_title, | ||
'content_quantity': -123.45 * 100, | ||
'content_quantity': -assignment_content_quantity_usd_cents, | ||
'state': LearnerContentAssignmentStateChoices.ALLOCATED, | ||
'transaction_uuid': None, | ||
'uuid': str(foo_record.uuid), | ||
|
@@ -623,7 +628,6 @@ def test_allocate_happy_path_e2e( | |
'reason': AssignmentAutomaticExpiredReason.NINETY_DAYS_PASSED | ||
} | ||
}] | ||
|
||
self.assertEqual(response_payload['created'], expected_created_records) | ||
|
||
canceled_record = allocation_records_by_email['[email protected]'] | ||
|
@@ -637,7 +641,7 @@ def test_allocate_happy_path_e2e( | |
'parent_content_key': self.parent_content_key, | ||
'is_assigned_course_run': True, | ||
'content_title': self.content_title, | ||
'content_quantity': -123.45 * 100, | ||
'content_quantity': -assignment_content_quantity_usd_cents, | ||
'state': LearnerContentAssignmentStateChoices.ALLOCATED, | ||
'transaction_uuid': None, | ||
'uuid': str(canceled_record.uuid), | ||
|
@@ -657,7 +661,7 @@ def test_allocate_happy_path_e2e( | |
'parent_content_key': self.parent_content_key, | ||
'is_assigned_course_run': True, | ||
'content_title': self.content_title, | ||
'content_quantity': -123.45 * 100, | ||
'content_quantity': -assignment_content_quantity_usd_cents, | ||
'state': LearnerContentAssignmentStateChoices.ALLOCATED, | ||
'transaction_uuid': None, | ||
'uuid': str(expired_record.uuid), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters