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
4 changes: 4 additions & 0 deletions ovh/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ def put(self, _target, _need_auth=True, **kwargs):
the default
"""
kwargs = self._canonicalize_kwargs(kwargs)
if not kwargs:
kwargs = None
return self.call('PUT', _target, kwargs, _need_auth)

def post(self, _target, _need_auth=True, **kwargs):
Expand All @@ -370,6 +372,8 @@ def post(self, _target, _need_auth=True, **kwargs):
the default
"""
kwargs = self._canonicalize_kwargs(kwargs)
if not kwargs:
kwargs = None
return self.call('POST', _target, kwargs, _need_auth)

def delete(self, _target, _need_auth=True, **kwargs):
Expand Down
12 changes: 12 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ def test_post(self, m_call):
self.assertEqual(m_call.return_value, api.post(FAKE_URL, **PAYLOAD))
m_call.assert_called_once_with('POST', FAKE_URL, PAYLOAD, True)

@mock.patch.object(Client, 'call')
def test_post_no_body(self, m_call):
api = Client(ENDPOINT, APPLICATION_KEY, APPLICATION_SECRET, CONSUMER_KEY)
self.assertEqual(m_call.return_value, api.post(FAKE_URL))
m_call.assert_called_once_with('POST', FAKE_URL, None, True)

@mock.patch.object(Client, 'call')
def test_put(self, m_call):
PAYLOAD = {
Expand All @@ -258,6 +264,12 @@ def test_put(self, m_call):
self.assertEqual(m_call.return_value, api.put(FAKE_URL, **PAYLOAD))
m_call.assert_called_once_with('PUT', FAKE_URL, PAYLOAD, True)

@mock.patch.object(Client, 'call')
def test_put_no_body(self, m_call):
api = Client(ENDPOINT, APPLICATION_KEY, APPLICATION_SECRET, CONSUMER_KEY)
self.assertEqual(m_call.return_value, api.put(FAKE_URL))
m_call.assert_called_once_with('PUT', FAKE_URL, None, True)

## test core function

@mock.patch('ovh.client.Session.request')
Expand Down