Repository: planetlabs/planet-client-python

Issue:
Implement CLI command: planet data search-delete
As specified in https://github.com/planetlabs/planet-client-python/blob/main/design-docs/CLI-Data.md#search-delete

Discussion:

Patch:
diff --git a/planet/cli/data.py b/planet/cli/data.py
index b730609..dc0bc8e 100644
--- a/planet/cli/data.py
+++ b/planet/cli/data.py
@@ -352,8 +352,19 @@ async def search_get(ctx, search_id, pretty):
         echo_json(items, pretty)
 
 
+@data.command()
+@click.pass_context
+@translate_exceptions
+@coro
+@click.argument('search_id')
+async def search_delete(ctx, search_id):
+    """Delete an existing saved search.
+    """
+    async with data_client(ctx) as cl:
+        await cl.delete_search(search_id)
+
+
 # TODO: search_update()".
-# TODO: search_delete()".
 # TODO: search_run()".
 # TODO: item_get()".
 # TODO: asset_activate()".


Test patch:
diff --git a/tests/integration/test_data_cli.py b/tests/integration/test_data_cli.py
index 109497c..881693c 100644
--- a/tests/integration/test_data_cli.py
+++ b/tests/integration/test_data_cli.py
@@ -53,6 +53,7 @@ def test_data_command_registered(invoke):
     assert "search" in result.output
     assert "search-create" in result.output
     assert "search-get" in result.output
+    assert "search-delete" in result.output
     # Add other sub-commands here.
 
 
@@ -701,9 +702,31 @@ def test_search_get_id_not_found(invoke, search_id):
     assert 'Error: {"message": "Error message"}\n' == result.output
 
 
+@respx.mock
+def test_search_delete_success(invoke, search_id, search_result):
+    delete_url = f'{TEST_SEARCHES_URL}/{search_id}'
+    mock_resp = httpx.Response(HTTPStatus.NO_CONTENT, json=search_result)
+    respx.delete(delete_url).return_value = mock_resp
+
+    result = invoke(['search-delete', search_id])
+
+    assert not result.exception
+
+
+@respx.mock
+def test_search_delete_nonexistant_search_id(invoke, search_id, search_result):
+    delete_url = f'{TEST_SEARCHES_URL}/{search_id}'
+    mock_resp = httpx.Response(404, json=search_result)
+    respx.delete(delete_url).return_value = mock_resp
+
+    result = invoke(['search-delete', search_id])
+
+    assert result.exception
+    assert result.exit_code == 1
+
+
 # TODO: basic test for "planet data search-create".
 # TODO: basic test for "planet data search-update".
-# TODO: basic test for "planet data search-delete".
 # TODO: basic test for "planet data search-get".
 # TODO: basic test for "planet data search-list".
 # TODO: basic test for "planet data search-run".