diff --git a/ovh/client.py b/ovh/client.py index 863b1ee..5105aef 100644 --- a/ovh/client.py +++ b/ovh/client.py @@ -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): @@ -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): diff --git a/tests/test_client.py b/tests/test_client.py index 0e5c5b3..8ccdec9 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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 = { @@ -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')