diff --git a/imap_data_access/io.py b/imap_data_access/io.py index c806115..c906164 100644 --- a/imap_data_access/io.py +++ b/imap_data_access/io.py @@ -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() diff --git a/tests/test_io.py b/tests/test_io.py index 9f7b96a..ebe833c 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -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