Skip to content

Commit a6d81db

Browse files
committed
yapf
1 parent c3c497d commit a6d81db

File tree

9 files changed

+69
-59
lines changed

9 files changed

+69
-59
lines changed

planet/cli/destinations.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ async def _patch_destination(ctx, destination_id, data, pretty):
3636
raise ClickException(f"Failed to patch destination: {e}")
3737

3838

39-
async def _list_destinations(ctx, archived, is_owner, can_write, is_default, pretty):
39+
async def _list_destinations(ctx,
40+
archived,
41+
is_owner,
42+
can_write,
43+
is_default,
44+
pretty):
4045
async with destinations_client(ctx) as cl:
4146
try:
4247
response = await cl.list_destinations(archived,
@@ -110,13 +115,17 @@ async def _get_default_destination(ctx, pretty):
110115
default=None,
111116
help="""Set to true to include only destinations the user can modify,
112117
false to exclude them.""")
113-
@click.option(
114-
'--is-default',
115-
type=bool,
116-
default=None,
117-
help="""Set to true to include only the default destination,
118+
@click.option('--is-default',
119+
type=bool,
120+
default=None,
121+
help="""Set to true to include only the default destination,
118122
false to exclude it.""")
119-
async def list_destinations(ctx, archived, is_owner, can_write, is_default, pretty):
123+
async def list_destinations(ctx,
124+
archived,
125+
is_owner,
126+
can_write,
127+
is_default,
128+
pretty):
120129
"""
121130
List destinations with optional filters
122131
@@ -127,7 +136,12 @@ async def list_destinations(ctx, archived, is_owner, can_write, is_default, pret
127136
128137
planet destinations list --archived false --is-owner true --can-write true
129138
"""
130-
await _list_destinations(ctx, archived, is_owner, can_write, is_default, pretty)
139+
await _list_destinations(ctx,
140+
archived,
141+
is_owner,
142+
can_write,
143+
is_default,
144+
pretty)
131145

132146

133147
@command(destinations, name="get")
@@ -677,4 +691,4 @@ async def get_default_destination(ctx, pretty):
677691
678692
planet destinations default get
679693
"""
680-
await _get_default_destination(ctx, pretty)
694+
await _get_default_destination(ctx, pretty)

planet/clients/destinations.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,11 @@ async def set_default_destination(self, destination_id: str) -> None:
198198
ClientError: If there is an issue with the client request.
199199
"""
200200
url = f'{self._base_url}/default'
201-
request = {
202-
"destination_id": destination_id
203-
}
201+
request = {"destination_id": destination_id}
204202
try:
205203
response = await self._session.request(method='PUT',
206-
url=url,
207-
json=request)
204+
url=url,
205+
json=request)
208206
except APIError:
209207
raise
210208
except ClientError: # pragma: no cover
@@ -253,4 +251,4 @@ async def get_default_destination(self) -> Dict:
253251
raise
254252
else:
255253
dest = response.json()
256-
return dest
254+
return dest

planet/order_request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ def s3_compatible(endpoint: str,
392392
return {'s3_compatible': parameters}
393393

394394

395-
def destination(destination_ref: str, path_prefix: Optional[str] = None) -> dict:
395+
def destination(destination_ref: str,
396+
path_prefix: Optional[str] = None) -> dict:
396397
"""Destinations API configuration.
397398
Parameters:
398399
destination_ref: Reference to an existing Destinations API

planet/subscription_request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ def s3_compatible(endpoint: str,
529529
return _delivery('s3_compatible', parameters)
530530

531531

532-
def destination(destination_ref: str, path_prefix: Optional[str] = None) -> dict:
532+
def destination(destination_ref: str,
533+
path_prefix: Optional[str] = None) -> dict:
533534
"""Specify a Destinations API destination by its ref.
534535
535536
Parameters:

planet/sync/destinations.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ def list_destinations(self,
5353
ClientError: If there is an issue with the client request.
5454
"""
5555
return self._client._call_sync(
56-
self._client.list_destinations(archived, is_owner, can_write, is_default))
56+
self._client.list_destinations(archived,
57+
is_owner,
58+
can_write,
59+
is_default))
5760

5861
def get_destination(self, destination_id: str) -> Dict:
5962
"""
@@ -154,5 +157,4 @@ def get_default_destination(self) -> Dict:
154157
APIError: If the API returns an error response.
155158
ClientError: If there is an issue with the client request.
156159
"""
157-
return self._client._call_sync(
158-
self._client.get_default_destination())
160+
return self._client._call_sync(self._client.get_default_destination())

tests/integration/test_destinations_api.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,12 @@ def assertf(resp):
198198
async def test_set_default_destination_bad_request():
199199
id = "invalid_dest_id"
200200
url = f"{TEST_URL}/default"
201-
mock_response(url, {
202-
"code": 400, "message": "Bad Request: Invalid destination ID"
203-
},
204-
method="put",
205-
status_code=HTTPStatus.BAD_REQUEST)
201+
mock_response(
202+
url, {
203+
"code": 400, "message": "Bad Request: Invalid destination ID"
204+
},
205+
method="put",
206+
status_code=HTTPStatus.BAD_REQUEST)
206207

207208
with pytest.raises(Exception):
208209
await cl_async.set_default_destination(id)
@@ -239,7 +240,10 @@ async def test_get_default_destination_not_found():
239240
@respx.mock
240241
async def test_unset_default_destination():
241242
url = f"{TEST_URL}/default"
242-
mock_response(url, None, method="delete", status_code=HTTPStatus.NO_CONTENT)
243+
mock_response(url,
244+
None,
245+
method="delete",
246+
status_code=HTTPStatus.NO_CONTENT)
243247

244248
# unset_default_destination returns None
245249
assert await cl_async.unset_default_destination() is None
@@ -249,11 +253,12 @@ async def test_unset_default_destination():
249253
@respx.mock
250254
async def test_unset_default_destination_unauthorized():
251255
url = f"{TEST_URL}/default"
252-
mock_response(url, {
253-
"code": 401, "message": "Unauthorized: Insufficient permissions"
254-
},
255-
method="delete",
256-
status_code=HTTPStatus.UNAUTHORIZED)
256+
mock_response(
257+
url, {
258+
"code": 401, "message": "Unauthorized: Insufficient permissions"
259+
},
260+
method="delete",
261+
status_code=HTTPStatus.UNAUTHORIZED)
257262

258263
with pytest.raises(Exception):
259264
await cl_async.unset_default_destination()

tests/integration/test_destinations_cli.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ def test_destinations_cli_default_set_bad_request(invoke):
273273
url = f"{TEST_DESTINATIONS_URL}/default"
274274
respx.put(url).return_value = httpx.Response(
275275
HTTPStatus.BAD_REQUEST,
276-
json={"code": 400, "message": "Bad Request: Invalid destination ID"})
276+
json={
277+
"code": 400, "message": "Bad Request: Invalid destination ID"
278+
})
277279

278280
result = invoke(['default', 'set', 'invalid-dest-id'])
279281
assert result.exit_code != 0
@@ -294,7 +296,9 @@ def test_destinations_cli_default_get_not_found(invoke):
294296
url = f"{TEST_DESTINATIONS_URL}/default"
295297
respx.get(url).return_value = httpx.Response(
296298
HTTPStatus.NOT_FOUND,
297-
json={"code": 404, "message": "No default destination configured"})
299+
json={
300+
"code": 404, "message": "No default destination configured"
301+
})
298302

299303
result = invoke(['default', 'get'])
300304
assert result.exit_code != 0
@@ -315,7 +319,9 @@ def test_destinations_cli_default_unset_unauthorized(invoke):
315319
url = f"{TEST_DESTINATIONS_URL}/default"
316320
respx.delete(url).return_value = httpx.Response(
317321
HTTPStatus.UNAUTHORIZED,
318-
json={"code": 401, "message": "Unauthorized: Insufficient permissions"})
322+
json={
323+
"code": 401, "message": "Unauthorized: Insufficient permissions"
324+
})
319325

320326
result = invoke(['default', 'unset'])
321327
assert result.exit_code != 0

tests/unit/test_order_request.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,7 @@ def test_fallback_bundle_invalid(bundle, fallback_bundle):
474474
def test_destination():
475475
dest_config = order_request.destination('my-dest-ref')
476476

477-
expected = {
478-
'destination': {
479-
'ref': 'my-dest-ref'
480-
}
481-
}
477+
expected = {'destination': {'ref': 'my-dest-ref'}}
482478
assert dest_config == expected
483479

484480

@@ -488,8 +484,7 @@ def test_destination_path_prefix():
488484

489485
expected = {
490486
'destination': {
491-
'ref': 'my-dest-ref',
492-
'path_prefix': 'my/prefix'
487+
'ref': 'my-dest-ref', 'path_prefix': 'my/prefix'
493488
}
494489
}
495490
assert dest_config == expected
@@ -498,11 +493,7 @@ def test_destination_path_prefix():
498493
def test_default_destination():
499494
dest_config = order_request.default_destination()
500495

501-
expected = {
502-
'destination': {
503-
'ref': 'pl:destinations/default'
504-
}
505-
}
496+
expected = {'destination': {'ref': 'pl:destinations/default'}}
506497
assert dest_config == expected
507498

508499

@@ -511,8 +502,7 @@ def test_default_destination_path_prefix():
511502

512503
expected = {
513504
'destination': {
514-
'ref': 'pl:destinations/default',
515-
'path_prefix': 'my/prefix'
505+
'ref': 'pl:destinations/default', 'path_prefix': 'my/prefix'
516506
}
517507
}
518508
assert dest_config == expected

tests/unit/test_subscription_request.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -639,23 +639,17 @@ def test_cloud_filter_tool_success():
639639
def test_destination_success():
640640
res = subscription_request.destination(destination_ref='my-dest-ref')
641641

642-
assert res == {
643-
"type": "destination",
644-
"parameters": {
645-
"ref": "my-dest-ref"
646-
}
647-
}
642+
assert res == {"type": "destination", "parameters": {"ref": "my-dest-ref"}}
648643

649644

650645
def test_destination_path_prefix_success():
651646
res = subscription_request.destination(destination_ref='my-dest-ref',
652-
path_prefix='my/prefix')
647+
path_prefix='my/prefix')
653648

654649
assert res == {
655650
"type": "destination",
656651
"parameters": {
657-
"ref": "my-dest-ref",
658-
"path_prefix": "my/prefix"
652+
"ref": "my-dest-ref", "path_prefix": "my/prefix"
659653
}
660654
}
661655

@@ -677,7 +671,6 @@ def test_default_destination_path_prefix_success():
677671
assert res == {
678672
"type": "destination",
679673
"parameters": {
680-
"ref": "pl:destinations/default",
681-
"path_prefix": "my/prefix"
674+
"ref": "pl:destinations/default", "path_prefix": "my/prefix"
682675
}
683676
}

0 commit comments

Comments
 (0)