Skip to content

Commit 9e3fba8

Browse files
committed
add page_size kwarg to list_subscriptions()
1 parent 91a2593 commit 9e3fba8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

planet/clients/subscriptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ async def list_subscriptions(
6969
self,
7070
status: Optional[Sequence[str]] = None,
7171
limit: int = 100,
72+
page_size: Optional[int] = None,
7273
created: Optional[str] = None,
7374
end_time: Optional[str] = None,
7475
hosting: Optional[bool] = None,
@@ -112,6 +113,7 @@ async def list_subscriptions(
112113
updated (str): filter by updated time or interval.
113114
limit (int): limit the number of subscriptions in the
114115
results. When set to 0, no maximum is applied.
116+
page_size (int): number of subscriptions to return per page, default 20.
115117
TODO: user_id
116118
117119
Datetime args (created, end_time, start_time, updated) can either be a
@@ -156,6 +158,8 @@ class _SubscriptionsPager(Paged):
156158
params['sort_by'] = sort_by
157159
if updated is not None:
158160
params['updated'] = updated
161+
if page_size is not None:
162+
params['page_size'] = page_size
159163

160164
try:
161165
response = await self._session.request(method='GET',

tests/integration/test_subscriptions_api.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,17 @@ async def test_list_subscriptions_filtering_and_sorting():
267267
]) == 2
268268

269269

270+
@pytest.mark.parametrize("page_size, count", [(50, 100), (100, 100)])
271+
@pytest.mark.anyio
272+
@api_mock
273+
async def test_list_subscriptions_page_size_success(page_size, count):
274+
async with Session() as session:
275+
client = SubscriptionsClient(session, base_url=TEST_URL)
276+
assert len([
277+
sub async for sub in client.list_subscriptions(page_size=page_size)
278+
]) == count
279+
280+
270281
@pytest.mark.anyio
271282
@failing_api_mock
272283
async def test_create_subscription_failure():

0 commit comments

Comments
 (0)