Skip to content
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
14 changes: 9 additions & 5 deletions imap_data_access/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,15 @@ def spice_query(
"Run 'query -h' for more information."
)

# Remap ingestion date params to /spice-query naming convention
if "ingestion_start_date" in query_params:
query_params["start_ingest_date"] = query_params.pop("ingestion_start_date")
if "ingestion_end_date" in query_params:
query_params["end_ingest_date"] = query_params.pop("ingestion_end_date")
# Remap date params to /spice-query naming convention
for cli_argument, spice_query_argument in [
("ingestion_start_date", "start_ingest_date"),
("ingestion_end_date", "end_ingest_date"),
("start_date", "start_time"),
("end_date", "end_time"),
]:
if cli_argument in query_params:
query_params[spice_query_argument] = query_params.pop(cli_argument)

url = f"{_get_base_url()}/spice-query"
request = requests.Request(method="GET", url=url, params=query_params).prepare()
Expand Down
12 changes: 8 additions & 4 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,14 @@ def test_spice_query(mock_send_request, query_params: dict):
if fixed_query.get("version") == "latest":
del fixed_query["version"]
fixed_query["latest"] = "true"
if "ingestion_start_date" in fixed_query:
fixed_query["start_ingest_date"] = fixed_query.pop("ingestion_start_date")
if "ingestion_end_date" in fixed_query:
fixed_query["end_ingest_date"] = fixed_query.pop("ingestion_end_date")
for cli_argument, spice_query_argument in [
("ingestion_start_date", "start_ingest_date"),
("ingestion_end_date", "end_ingest_date"),
("start_date", "start_time"),
("end_date", "end_time"),
]:
if cli_argument in fixed_query:
fixed_query[spice_query_argument] = fixed_query.pop(cli_argument)
str_params = "&".join(f"{k}={v}" for k, v in fixed_query.items())
expected_url_encoded = f"https://api.test.com/spice-query?{str_params}"
assert called_url == expected_url_encoded
Expand Down
Loading