diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2018-04-03 06:23:42 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2018-04-12 08:00:05 +0000 |
commit | 5ac59e495d74b64ab377f1ba25bb00b11da14e67 (patch) | |
tree | 9a12de435a5c14a7f3477b931a120fc660b63bdb /yardstick/tests/unit/common/test_openstack_utils.py | |
parent | 374a6caf766c0503f114a83cc20144f72b10ab45 (diff) |
Bugfix: Can't get image list in API
JIRA: YARDSTICK-1110
To match OpenStack Pike release, we upgrade novaclient from 7.1.1 to 9.1.1.
And the client interface has changed, it no longer has nova_client.images attribute.
So I use shade instead. Later will change all same issue.
Change-Id: Ie4f54069d4346e44e2ad925439930504b945cbad
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/tests/unit/common/test_openstack_utils.py')
-rw-r--r-- | yardstick/tests/unit/common/test_openstack_utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py index 3b7e8eaa1..5c7e5bfab 100644 --- a/yardstick/tests/unit/common/test_openstack_utils.py +++ b/yardstick/tests/unit/common/test_openstack_utils.py @@ -264,3 +264,21 @@ class CreateSecurityGroupRuleTestCase(unittest.TestCase): self.mock_shade_client, self.secgroup_name_or_id) mock_logger.error.assert_called_once() self.assertFalse(output) + + +class ListImageTestCase(unittest.TestCase): + + def test_list_images(self): + mock_shade_client = mock.MagicMock() + mock_shade_client.list_images.return_value = [] + openstack_utils.list_images(mock_shade_client) + + @mock.patch.object(openstack_utils, 'log') + def test_list_images_exception(self, mock_logger): + mock_shade_client = mock.MagicMock() + mock_shade_client.list_images = mock.MagicMock() + mock_shade_client.list_images.side_effect = ( + exc.OpenStackCloudException('error message')) + images = openstack_utils.list_images(mock_shade_client) + mock_logger.error.assert_called_once() + self.assertFalse(images) |