From 8c8cbe6ae09a7930bd909382cd093a8c8f5eb694 Mon Sep 17 00:00:00 2001 From: Thomas Chopitea Date: Tue, 29 Sep 2026 17:47:58 +0000 Subject: [PATCH] Dispatch DELETE in do_request do_request raised ValueError("Unsupported method: DELETE") for anything but GET, POST and PATCH, so no client method could delete an object and callers had to reach past the wrapper into self.client. That also skipped the 401 refresh-and-retry and the YetiApiError wrapping that every other call gets. No delete_* convenience methods yet; this only removes what blocked them. Version bumped to 2.4.0 so the release can be cut without a second commit on main. --- pyproject.toml | 2 +- tests/api.py | 15 +++++++++++++++ yeti/api.py | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8050ea8..025519b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "yeti-python" -version = "2.3.1" +version = "2.4.0" description = "Python bindings for the Yeti API" authors = ["tomchop"] license = "Apache" diff --git a/tests/api.py b/tests/api.py index 6374734..2708ad8 100644 --- a/tests/api.py +++ b/tests/api.py @@ -631,6 +631,21 @@ def test_patch_agent_persona(self, mock_patch): json={"persona": {"name": "Renamed"}}, ) + @patch("yeti.api.requests.Session.delete") + def test_do_request_delete(self, mock_delete): + mock_response = MagicMock() + mock_response.content = b"" + mock_delete.return_value = mock_response + + result = self.api.do_request("DELETE", "http://fake-url/api/v2/dfiq/1") + self.assertEqual(result, b"") + mock_delete.assert_called_with("http://fake-url/api/v2/dfiq/1") + + def test_do_request_rejects_unknown_methods(self): + with self.assertRaises(ValueError) as error: + self.api.do_request("TRACE", "http://fake-url/api/v2/dfiq/1") + self.assertIn("Unsupported method: TRACE", str(error.exception)) + if __name__ == "__main__": unittest.main() diff --git a/yeti/api.py b/yeti/api.py index 59f8aad..12b5974 100644 --- a/yeti/api.py +++ b/yeti/api.py @@ -144,6 +144,8 @@ def do_request( response = self.client.patch(url, **request_kwargs) elif method == "GET": response = self.client.get(url, **request_kwargs) + elif method == "DELETE": + response = self.client.delete(url, **request_kwargs) else: raise ValueError(f"Unsupported method: {method}") response.raise_for_status()