Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adhering transaction api list view to edx rest framework default pagination #188

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading