diff --git a/databricks/sdk/core.py b/databricks/sdk/core.py index bbb45310e..ebf3aa185 100644 --- a/databricks/sdk/core.py +++ b/databricks/sdk/core.py @@ -145,11 +145,14 @@ def do(self, if not len(response.content): return resp - json = response.json() - if isinstance(json, list): - return json + jsonResponse = response.json() + if jsonResponse is None: + return resp + + if isinstance(jsonResponse, list): + return jsonResponse - return {**resp, **json} + return {**resp, **jsonResponse} @staticmethod def _is_retryable(err: BaseException) -> Optional[str]: diff --git a/tests/test_core.py b/tests/test_core.py index aed659b3b..3ca6ca830 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -335,6 +335,21 @@ def test_shares(config, requests_mock): assert requests_mock.last_request.json() == {'changes': [{'principal': 'principal'}]} +def test_deletes(config, requests_mock): + requests_mock.delete("http://localhost/api/2.0/preview/sql/alerts/alertid", + request_headers={"User-Agent": config.user_agent}, + text="null", + ) + + w = WorkspaceClient(config=config) + res = w.alerts.delete(alert_id="alertId") + + assert requests_mock.call_count == 1 + assert requests_mock.called + + assert res is None + + def test_error(config, requests_mock): errorJson = { "message":