Merge "Report Client: PUT empty (not None) JSON data"

This commit is contained in:
Zuul 2018-01-27 22:35:50 +00:00 committed by Gerrit Code Review
commit 6e9d135639
2 changed files with 10 additions and 1 deletions

View File

@ -298,7 +298,7 @@ class SchedulerReportClient(object):
# more sensitive to this than other APIs in the OpenStack
# ecosystem.
kwargs = {'microversion': version}
if data:
if data is not None:
kwargs['json'] = data
return self._client.put(url, raise_exc=False, **kwargs)

View File

@ -1801,6 +1801,15 @@ class TestProviderOperations(SchedulerReportClientTestCase):
self.assertEqual(uuids.request_id,
logging_mock.call_args[0][1]['placement_req_id'])
def test_put_empty(self):
# A simple put with an empty (not None) payload should send the empty
# payload through.
# Bug #1744786
url = '/resource_providers/%s/aggregates' % uuids.foo
self.client.put(url, [])
self.ks_adap_mock.put.assert_called_once_with(
url, json=[], raise_exc=False, microversion=None)
class TestAggregates(SchedulerReportClientTestCase):
def test_get_provider_aggregates_found(self):