Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datadog/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
_max_retries = 3
_backoff_period = 300
_mute = True
_return_raw_response = False

# Resources
from datadog.api.comments import Comment
Expand Down
42 changes: 39 additions & 3 deletions tests/unit/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really convinced by the usefulness of this test. It won't prevent anyone to not add settings in the init later. What do you think?

_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.
Expand Down Expand Up @@ -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):
"""
Expand Down