Skip to content

test: add unit tests for Paginator class — core pagination logic has no direct coverage #130

@ausbernard

Description

@ausbernard

Gap

Paginator is a core feature — it's the engine behind every .all() call in the library — but it has zero direct unit
tests. It's only exercised indirectly through integration tests like test_customers_all_pages, which test the full HTTP
stack rather than the pagination logic itself.

Tests Added

tests/paginator_test.py covers the paginator in isolation using unittest.mock (no HTTP mocking needed):

Test What it proves
test_single_page_yields_all_records Stops after one fetch when no after cursor
test_multiple_pages_follows_cursor Follows cursors until None, collects all records
test_after_cursor_passed_to_next_fetch Cursor value actually makes it into the next request params
test_empty_page_yields_nothing Graceful handling of empty responses
test_params_passed_to_service Filter params reach the service
test_identity_params_passed_to_service Nested resource params (e.g. creditor_id) pass through correctly
test_original_params_not_mutated The params dict passed in isn't modified during iteration
collected 7 items

tests/paginator_test.py::test_single_page_yields_all_records PASSED
tests/paginator_test.py::test_multiple_pages_follows_cursor PASSED
tests/paginator_test.py::test_after_cursor_passed_to_next_fetch PASSED
tests/paginator_test.py::test_empty_page_yields_nothing PASSED
tests/paginator_test.py::test_params_passed_to_service PASSED
tests/paginator_test.py::test_identity_params_passed_to_service PASSED
tests/paginator_test.py::test_original_params_not_mutated PASSED

7 passed in 0.31s

PR Ready

Branch at ausbernard/gocardless-pro-pythonchore/paginator-test. Same collaborator access situation as my
previous issue — happy to contribute if a PR can be opened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions