Skip to content

subscriptions: make source type optional for planetary_variable_source function #1125

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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/cli/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,10 @@ def request_pv(var_type, var_id, geometry, start_time, end_time, pretty):
more details.
"""
res = subscription_request.planetary_variable_source(
var_type,
var_id,
geometry,
start_time,
var_type=var_type,
end_time=end_time,
)
echo_json(res, pretty)
Expand Down
8 changes: 4 additions & 4 deletions planet/subscription_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ def catalog_source(


def planetary_variable_source(
var_type: Optional[str],
var_id: str,
geometry: Union[dict, str],
start_time: datetime,
var_type: Optional[str] = None,
end_time: Optional[datetime] = None,
) -> dict:
"""Construct a Planetary Variable subscription source.
Expand All @@ -304,16 +304,16 @@ def planetary_variable_source(
Note: this function does not validate variable types and ids.

Parameters:
var_type: Planetary Variable type. See documentation for all
available types. Used to be a required parameter but
is now optional and can be 'None'.
var_id: A Planetary Variable ID. See documenation for all
available IDs.
geometry: The area of interest of the subscription that will be
used to determine matches. May be a geojson-like dict or a
Features API geometry reference (string)
start_time: The start time of the subscription. This time can be
in the past or future.
var_type: Planetary Variable type. See documentation for all
available types. Used to be a required parameter but
is now optional and can be 'None'.
end_time: The end time of the subscription. This time can be in
the past or future, and must be after the start_time.

Expand Down
13 changes: 12 additions & 1 deletion tests/unit/test_subscription_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,10 @@ def test_toar_tool_success():
def test_pv_source_success(geom_geojson, var_type, var_id):
"""Configure a planetary variable subscription source."""
source = subscription_request.planetary_variable_source(
var_type,
var_id,
geometry=geom_geojson,
start_time=datetime(2021, 3, 1),
var_type=var_type,
end_time=datetime(2021, 3, 2),
)

Expand All @@ -593,6 +593,17 @@ def test_pv_source_success(geom_geojson, var_type, var_id):
assert params["start_time"].startswith("2021-03-01")


def test_pv_source_no_type(geom_geojson):
"""Configure a planetary variable subscription source."""
source = subscription_request.planetary_variable_source(
"BIOMASS-PROXY_V3.0_10",
geometry=geom_geojson,
start_time=datetime(2021, 3, 1),
end_time=datetime(2021, 3, 2),
)
assert source.get("type") is None


@respx.mock
@pytest.mark.parametrize(
# Test all the combinations of the three options plus some with dupes.
Expand Down