diff --git a/datadog/api/__init__.py b/datadog/api/__init__.py index 31ca0bc5b..0df05bd95 100644 --- a/datadog/api/__init__.py +++ b/datadog/api/__init__.py @@ -16,6 +16,7 @@ _max_retries = 3 _backoff_period = 300 _mute = True +_return_raw_response = False # Resources from datadog.api.comments import Comment diff --git a/tests/unit/api/test_api.py b/tests/unit/api/test_api.py index ca589b089..63d795423 100644 --- a/tests/unit/api/test_api.py +++ b/tests/unit/api/test_api.py @@ -43,6 +43,42 @@ class TestInitialization(DatadogAPINoInitialization): + def test_default_settings_set(self): + """ + Test all the default setting are properly set before calling initialize + """ + from datadog.api import ( + _api_key, + _application_key, + _api_version, + _api_host, + _host_name, + _hostname_from_config, + _cacert, + _proxies, + _timeout, + _max_timeouts, + _max_retries, + _backoff_period, + _mute, + _return_raw_response, + ) + + assert _api_key is None + assert _application_key is None + assert _api_version == 'v1' + assert _api_host is None + assert _host_name is None + assert _hostname_from_config is True + assert _cacert is True + assert _proxies is None + assert _timeout == 60 + assert _max_timeouts == 3 + assert _max_retries == 3 + assert _backoff_period == 300 + assert _mute is True + assert _return_raw_response is False + def test_no_initialization_fails(self): """ Raise ApiNotInitialized exception when `initialize` has not ran or no API key was set. @@ -116,14 +152,14 @@ def test_request_parameters_api_keys_in_params(self): self.assertIn('params', options) self.assertIn('headers', options) - + # for resources in MyParamsApiKey, api key and application key needs to be in url params # any api and app keys in headers are ignored self.assertEqual(options['headers']['Content-Type'], 'application/json') self.assertEqual(options['params']['api_key'], API_KEY) self.assertEqual(options['params']['application_key'], APP_KEY) - - + + def test_initialize_options(self): """