Skip to content

simplify geojson specified as geometry in catalog_source #880

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 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion planet/subscription_request.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice and simple solution :)

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def catalog_source(
parameters = {
"item_types": item_types,
"asset_types": asset_types,
"geometry": geometry,
"geometry": geojson.as_geom(geometry),
}

try:
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test_subscription_request.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Solid test!

Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,30 @@ def test_catalog_source_success(geom_geojson):
assert res == expected


def test_catalog_source_featurecollection(featurecollection_geojson,
geom_geojson):
'''geojson specified as featurecollection is simplified down to just
the geometry'''
res = subscription_request.catalog_source(
item_types=["PSScene"],
asset_types=["ortho_analytic_4b"],
geometry=featurecollection_geojson,
start_time=datetime(2021, 3, 1),
)

expected = {
"type": "catalog",
"parameters": {
"geometry": geom_geojson,
"start_time": "2021-03-01T00:00:00Z",
"item_types": ["PSScene"],
"asset_types": ["ortho_analytic_4b"]
}
}

assert res == expected


def test_catalog_source_invalid_start_time(geom_geojson):
with pytest.raises(exceptions.ClientError):
subscription_request.catalog_source(
Expand Down