Skip to content

Commit

Permalink
Add tests for PageIterator in test_pagination.py
Browse files Browse the repository at this point in the history
These tests improve coverage and ensure proper behavior of
`PageIterator` with rate limiting and page size adjustments.
  • Loading branch information
vchrombie committed Sep 13, 2024
1 parent 4b86304 commit aab9e38
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_pagination.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pynamodb.pagination import RateLimiter
from pynamodb.pagination import RateLimiter, PageIterator


class MockTime():
Expand Down Expand Up @@ -77,3 +77,25 @@ def test_basic_rate_limiting_large_increment():

# The operation takes longer than the minimum wait, so rate limiting should have no effect
assert mock_time.time() == 1100.0


def test_page_iterator_with_rate_limit():
def mock_operation():
pass

args = None
kwargs = {'exclusive_start_key': None}
rate_limit = 0.1
page_iter = PageIterator(mock_operation, args, kwargs, rate_limit)
assert page_iter._rate_limiter.rate_limit == rate_limit


def test_page_iterator_page_size_getter():
page_iter = PageIterator(None, None, {'limit': 10})
assert page_iter.page_size == 10


def test_page_iterator_page_size_setter():
page_iter = PageIterator(None, None, {})
page_iter.page_size = 20
assert page_iter._kwargs['limit'] == 20

0 comments on commit aab9e38

Please sign in to comment.