Merge "Fix error about request validate for image_search"

This commit is contained in:
Zuul 2018-03-08 10:54:15 +00:00 committed by Gerrit Code Review
commit 478e5c8621
2 changed files with 7 additions and 5 deletions

View File

@ -144,8 +144,8 @@ class Manager(object):
url = "%s?%s" % (url, urlparse.urlencode(qparams)) url = "%s?%s" % (url, urlparse.urlencode(qparams))
self.api.raw_request('DELETE', url) self.api.raw_request('DELETE', url)
def _search(self, url, body=None, response_key=None, obj_class=None, def _search(self, url, qparams=None, response_key=None, obj_class=None,
qparams=None): body=None):
if qparams: if qparams:
url = "%s?%s" % (url, urlparse.urlencode(qparams)) url = "%s?%s" % (url, urlparse.urlencode(qparams))

View File

@ -91,7 +91,8 @@ fake_responses = {
{'images': [IMAGE2, IMAGE1]}, {'images': [IMAGE2, IMAGE1]},
), ),
}, },
'/v1/images/%s/search' % IMAGE3['image']: '/v1/images/%s/search?image_driver=%s' % (IMAGE3['image'],
IMAGE3['image_driver']):
{ {
'GET': ( 'GET': (
{}, {},
@ -182,9 +183,10 @@ class ImageManagerTest(testtools.TestCase):
def test_image_search(self): def test_image_search(self):
images = self.mgr.search_image(**SEARCH_IMAGE) images = self.mgr.search_image(**SEARCH_IMAGE)
url = '/v1/images/%s/search?image_driver=%s' \
% (IMAGE3['image'], IMAGE3['image_driver'])
expect = [ expect = [
('GET', '/v1/images/%s/search' % IMAGE3['image'], {}, ('GET', url, {}, None),
{'image_driver': IMAGE3['image_driver']}),
] ]
self.assertEqual(expect, self.api.calls) self.assertEqual(expect, self.api.calls)
self.assertThat(images, matchers.HasLength(1)) self.assertThat(images, matchers.HasLength(1))