Skip to content

Commit

Permalink
fix: paginate pages of user transactions correctly. ENT-7637
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Sep 5, 2023
1 parent 3267289 commit 6e6cef4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions enterprise_access/apps/subsidy_access_policy/subsidy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def get_and_cache_transactions_for_learner(subsidy_uuid, lms_user_id):
next_page = response_payload.get('next')
while next_page:
next_response = client.client.get(next_page)
result['transactions'].extend(next_response['results'])
next_page = next_response.get('next')
next_payload = next_response.json()
result['transactions'].extend(next_payload['results'])
next_page = next_payload.get('next')

logger.info(
'Fetched transactions for subsidy %s and lms_user_id %s. Number transactions = %s',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def test_multiple_pages_are_traversed(self, mock_client_getter):
}
mock_client = mock_client_getter.return_value
mock_client.list_subsidy_transactions.return_value = first_response_payload
mock_client.client.get.return_value = second_response_payload
mock_second_response = mock.Mock()
mock_second_response.json.return_value = second_response_payload
mock_client.client.get.return_value = mock_second_response

subsidy_uuid = uuid.uuid4()
lms_user_id = 42
Expand Down

0 comments on commit 6e6cef4

Please sign in to comment.