Skip to content

Update requesting orders #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jun 7, 2022
Merged

Update requesting orders #519

merged 32 commits into from
Jun 7, 2022

Conversation

kevinlacaille
Copy link
Contributor

Created orders request skeleton

@kevinlacaille kevinlacaille added the CLI/SDK Interface Update the CLI and SDK to the finalized interface label May 5, 2022
@kevinlacaille kevinlacaille added this to the Data CLI MVP milestone May 5, 2022
@kevinlacaille kevinlacaille self-assigned this May 5, 2022
@kevinlacaille
Copy link
Contributor Author

kevinlacaille commented May 13, 2022

Now to implement:

  • stdin for create()
    • associated tests

Comment on lines +473 to +474
mock_resp = httpx.Response(HTTPStatus.OK, json=order_description)
respx.post(TEST_ORDERS_URL).return_value = mock_resp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not high priority, but it would be cool if we could find a way to hoist these lines up above the body of the function. For clarity. I don't know enough about respx to see how to do it, though.

sent_request = json.loads(respx.calls.last.request.content)
assert sent_request == order_request


@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of testing the permutation of id strings in multiple tests?

Copy link
Contributor Author

@kevinlacaille kevinlacaille Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took most tests for create and translated them for request, simply because a lot of create's functionality was transferred over to request. The permutation of ID strings was just something that we did for this test back when it was for create. Thoughts on removing it? cc @sarasafavi

f'--id={id_string}',
'--bundle=analytic',
'--item-type=PSOrthoTile'
])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinlacaille I think it would be better to invoke planet-data-request and planet-data-create in different tests, not in the same test. Then we'll have two simpler tests (no temp JSON file) that will be easier to read and modify down the road.

Comment on lines 847 to 850
def test_cli_orders_request_tools(invoke, geom_geojson,
write_to_tmp_json_file):
tools_json = [{'clip': {'aoi': geom_geojson}}, {'composite': {}}]
tools_file = write_to_tmp_json_file(tools_json, 'tools.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinlacaille what would you think about combining geom_geojson and write_to_tmp_json_file into a single pytest fixture? Something like this:

Suggested change
def test_cli_orders_request_tools(invoke, geom_geojson,
write_to_tmp_json_file):
tools_json = [{'clip': {'aoi': geom_geojson}}, {'composite': {}}]
tools_file = write_to_tmp_json_file(tools_json, 'tools.json')
@pytest.fixture
def tools_file(geom_geojson, write_to_tmp_json_file):
tools_json = [{'clip': {'aoi': geom_geojson}}, {'composite': {}}]
return write_to_tmp_json_file(tools_json, 'tools.json')
def test_cli_orders_request_tools(invoke, tools_file):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a useful pattern for the cloud config files too?

Copy link
Contributor

@sgillies sgillies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinlacaille this is excellent work. I have a few comments and suggestions. I hope you find them helpful!

@mkshah605
Copy link
Contributor

Lots of good feedback here. I think this looks great @kevinlacaille !!

@kevinlacaille
Copy link
Contributor Author

Let's get this merged and we'll deal with more cosmetic / less consequential fixes in this issue: #584
cc: @jreiberkyle @sgillies @sarasafavi

@kevinlacaille kevinlacaille merged commit 87f9dab into main Jun 7, 2022
@jreiberkyle jreiberkyle deleted the update-requesting-orders-366 branch June 14, 2022 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI/SDK Interface Update the CLI and SDK to the finalized interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update create order command, break out and create separate command for building request
4 participants