Merge "Always use application/json accept header in report client"

This commit is contained in:
Jenkins
2017-08-14 22:56:36 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 3 deletions

View File

@@ -236,8 +236,13 @@ class SchedulerReportClient(object):
self._provider_aggregate_map = {}
auth_plugin = keystone.load_auth_from_conf_options(
CONF, 'placement')
# Set content-type and accept on every request to ensure we notify
# placement service of our request and response body media type
# preferences.
self._client = keystone.load_session_from_conf_options(
CONF, 'placement', auth=auth_plugin)
CONF, 'placement', auth=auth_plugin,
additional_headers={'accept': 'application/json'})
# NOTE(danms): Keep track of how naggy we've been
self._warn_count = 0
self.ks_filter = {'service_type': 'placement',

View File

@@ -141,7 +141,8 @@ class TestConstructor(test.NoDBTestCase):
load_auth_mock.assert_called_once_with(CONF, 'placement')
load_sess_mock.assert_called_once_with(CONF, 'placement',
auth=load_auth_mock.return_value)
additional_headers={'accept': 'application/json'},
auth=load_auth_mock.return_value)
self.assertIsNone(client.ks_filter['interface'])
@mock.patch('keystoneauth1.loading.load_session_from_conf_options')
@@ -152,7 +153,8 @@ class TestConstructor(test.NoDBTestCase):
load_auth_mock.assert_called_once_with(CONF, 'placement')
load_sess_mock.assert_called_once_with(CONF, 'placement',
auth=load_auth_mock.return_value)
additional_headers={'accept': 'application/json'},
auth=load_auth_mock.return_value)
self.assertEqual('admin', client.ks_filter['interface'])