Skip to content

Commit

Permalink
feat: adhering transaction api list view to edx rest framework defaul…
Browse files Browse the repository at this point in the history
…t pagination
  • Loading branch information
alex-sheehan-edx committed Dec 11, 2023
1 parent 6a67117 commit e292ee4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion enterprise_subsidy/apps/api/paginators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"""
from math import ceil

from edx_rest_framework_extensions.paginators import DefaultPagination
from rest_framework import pagination

from ..subsidy.models import Subsidy


class TransactionListPaginator(pagination.PageNumberPagination):
class TransactionListPaginator(DefaultPagination):
"""
Optionally adds an `aggregates` dictionary to the base pagination response
of transaction list views.
Expand Down
14 changes: 14 additions & 0 deletions enterprise_subsidy/apps/api/v2/tests/test_transaction_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,20 @@ def test_admin_list_transactions_happy_path_no_filters(
self._prepend_initial_transaction_uuid(subsidy_uuid, expected_response_uuids)
self.assertEqual(sorted(response_uuids), sorted(expected_response_uuids))

def test_admin_list_transactions_default_pagination_behavior(self):
"""
Test listing of Transaction records for an admin or operator adheres to edx rest framework default pagination.
"""
self.set_up_operator()
subsidy_uuid = APITestBase.subsidy_3_uuid
url = reverse("api:v2:transaction-admin-list-create", args=[subsidy_uuid])

response = self.client.get(url)
assert "num_pages" in response.data.keys()
assert "count" in response.data.keys()
assert "current_page" in response.data.keys()
assert "results" in response.data.keys()

@ddt.data('admin', 'operator')
def test_admin_list_transactions_happy_path_with_filters(self, role):
"""
Expand Down

0 comments on commit e292ee4

Please sign in to comment.