From aab9e3821e9f35bf328d4c4d47b46739a06463d5 Mon Sep 17 00:00:00 2001 From: Venu Vardhan Reddy Tekula Date: Tue, 10 Sep 2024 17:13:46 -0400 Subject: [PATCH] Add tests for `PageIterator` in `test_pagination.py` These tests improve coverage and ensure proper behavior of `PageIterator` with rate limiting and page size adjustments. --- tests/test_pagination.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/test_pagination.py b/tests/test_pagination.py index c7fb1dc29..960e02a60 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -1,5 +1,5 @@ import pytest -from pynamodb.pagination import RateLimiter +from pynamodb.pagination import RateLimiter, PageIterator class MockTime(): @@ -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