Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions planet/clients/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async def list_subscriptions(
self,
status: Optional[Sequence[str]] = None,
limit: int = 100,
page_size: Optional[int] = None,
created: Optional[str] = None,
end_time: Optional[str] = None,
hosting: Optional[bool] = None,
Expand Down Expand Up @@ -112,6 +113,7 @@ async def list_subscriptions(
updated (str): filter by updated time or interval.
limit (int): limit the number of subscriptions in the
results. When set to 0, no maximum is applied.
page_size (int): number of subscriptions to return per page, default 20.
TODO: user_id

Datetime args (created, end_time, start_time, updated) can either be a
Expand Down Expand Up @@ -156,6 +158,8 @@ class _SubscriptionsPager(Paged):
params['sort_by'] = sort_by
if updated is not None:
params['updated'] = updated
if page_size is not None:
params['page_size'] = page_size

try:
response = await self._session.request(method='GET',
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_subscriptions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ async def test_list_subscriptions_filtering_and_sorting():
]) == 2


@pytest.mark.parametrize("page_size, count", [(50, 100), (100, 100)])
@pytest.mark.anyio
@api_mock
async def test_list_subscriptions_page_size_success(page_size, count):
async with Session() as session:
client = SubscriptionsClient(session, base_url=TEST_URL)
assert len([
sub async for sub in client.list_subscriptions(page_size=page_size)
]) == count


@pytest.mark.anyio
@failing_api_mock
async def test_create_subscription_failure():
Expand Down
Loading