Change ImagesClient API call

If image_id is specified in CLI, tempestconf will fail
on AttributeError. Therefor .get_image call is changed
for .show_image.

Change-Id: I29017ea2b47cf51f3990c2597fd8e844ebf63caa
This commit is contained in:
Martin Kopec 2017-08-14 23:33:58 +00:00
parent 622bb4fa31
commit 1256ee1a48
2 changed files with 11 additions and 1 deletions

View File

@ -1021,7 +1021,7 @@ def _find_image(client, image_id, image_name):
"""Find image by ID or name (the image client doesn't have this)."""
if image_id:
try:
return client.get_image(image_id)
return client.show_image(image_id)
except exceptions.NotFound:
pass
found = filter(lambda x: x['name'] == image_name,

View File

@ -107,6 +107,16 @@ class TestFindImage(BaseConfigTempestTest):
image_name="DoesNotExist",
expected_resp=None)
def test_find_image_by_id(self):
expected_resp = {"id": "001", "status": "active", "name": "ImageName"}
mock_function = mock.Mock(return_value=expected_resp)
func2mock = self.CLIENT_MOCK + '.show_image'
self.useFixture(MonkeyPatch(func2mock, mock_function))
resp = tool._find_image(client=self.client,
image_id="001",
image_name="cirros")
self.assertEqual(resp, expected_resp)
class TestFindOrUploadImage(BaseConfigTempestTest):