Skip to content

Commit 3ae25f9

Browse files
authored
hotfix: omit page_size arg to client call if not provided in subs cli list command (#1102)
* omit page_size if not provided in subs cli list * format * add more test coverage
1 parent 187611c commit 3ae25f9

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

planet/cli/subscriptions.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,24 @@ async def list_subscriptions_cmd(ctx,
128128
pretty):
129129
"""Prints a sequence of JSON-encoded Subscription descriptions."""
130130
async with subscriptions_client(ctx) as client:
131+
list_subscriptions_kwargs = {
132+
'created': created,
133+
'end_time': end_time,
134+
'hosting': hosting,
135+
'name__contains': name_contains,
136+
'name': name,
137+
'source_type': source_type,
138+
'start_time': start_time,
139+
'status': status,
140+
'sort_by': sort_by,
141+
'updated': updated,
142+
'limit': limit,
143+
}
144+
if page_size is not None:
145+
list_subscriptions_kwargs['page_size'] = page_size
146+
131147
async for sub in client.list_subscriptions(
132-
created=created,
133-
end_time=end_time,
134-
hosting=hosting,
135-
name__contains=name_contains,
136-
name=name,
137-
source_type=source_type,
138-
start_time=start_time,
139-
status=status,
140-
sort_by=sort_by,
141-
updated=updated,
142-
limit=limit,
143-
page_size=page_size):
148+
**list_subscriptions_kwargs):
144149
echo_json(sub, pretty)
145150

146151

tests/integration/test_subscriptions_api.py

+20
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,16 @@ async def test_list_subscriptions_cycle_break():
562562
_ = [sub async for sub in client.list_subscriptions()]
563563

564564

565+
@pytest.mark.anyio
566+
@failing_api_mock
567+
async def test_get_summary_failure():
568+
"""ServerError is raised if there is an internal server error (500)."""
569+
with pytest.raises(ServerError):
570+
async with Session() as session:
571+
client = SubscriptionsClient(session, base_url=TEST_URL)
572+
_ = await client.get_summary()
573+
574+
565575
@pytest.mark.anyio
566576
@summary_mock
567577
async def test_get_summary():
@@ -601,6 +611,16 @@ def test_get_summary_sync():
601611
}
602612

603613

614+
@pytest.mark.anyio
615+
@failing_api_mock
616+
async def test_get_sub_summary_failure():
617+
"""ServerError is raised if there is an internal server error (500)."""
618+
with pytest.raises(ServerError):
619+
async with Session() as session:
620+
client = SubscriptionsClient(session, base_url=TEST_URL)
621+
_ = await client.get_subscription_summary("test")
622+
623+
604624
@pytest.mark.anyio
605625
@sub_summary_mock
606626
async def test_get_sub_summary():

0 commit comments

Comments
 (0)