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()