Merge pull request #47720 from tchaikov/wip-mgr-dashboard-test-with-headers

qa/tasks/mgr/dashboard: accept headers as a param

Reviewed-by: Nizamudeen A <nia@redhat.com>
This commit is contained in:
Kefu Chai 2022-08-22 22:34:57 +08:00 committed by GitHub
commit 4bb9b6c424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -277,10 +277,11 @@ class DashboardTestCase(MgrTestCase):
# pylint: disable=inconsistent-return-statements, too-many-arguments, too-many-branches
@classmethod
def _request(cls, url, method, data=None, params=None, version=DEFAULT_API_VERSION,
set_cookies=False):
set_cookies=False, headers=None):
url = "{}{}".format(cls._base_uri, url)
log.debug("Request %s to %s", method, url)
headers = {}
if headers is None:
headers = {}
cookies = {}
if cls._token:
if set_cookies:
@ -336,8 +337,9 @@ class DashboardTestCase(MgrTestCase):
raise ex
@classmethod
def _get(cls, url, params=None, version=DEFAULT_API_VERSION, set_cookies=False):
return cls._request(url, 'GET', params=params, version=version, set_cookies=set_cookies)
def _get(cls, url, params=None, version=DEFAULT_API_VERSION, set_cookies=False, headers=None):
return cls._request(url, 'GET', params=params, version=version,
set_cookies=set_cookies, headers=headers)
@classmethod
def _view_cache_get(cls, url, retries=5):

View File

@ -15,12 +15,10 @@ class RequestsTest(DashboardTestCase):
})
def test_force_no_gzip(self):
self._get('/api/summary', params=dict(
headers={'Accept-Encoding': 'identity'}
))
self._get('/api/summary', headers={'Accept-Encoding': 'identity'})
self.assertNotIn('Content-Encoding', self._resp.headers)
self.assertHeaders({
'Content-Type': 'application/json'
'Content-Type': 'application/vnd.ceph.api.v{}+json'.format(DEFAULT_API_VERSION)
})
def test_server(self):