aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/common/test_openstack_utils.py
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-03-30 10:45:54 +0100
committerShobhi Jain <shobhi.jain@intel.com>2018-05-03 08:24:18 +0000
commitd75a91ebf2937e5cfe5cf2aa5a90db9121f73967 (patch)
treefd6440ec4e0f1b7bb0d500f0a06a8a01699a8d64 /yardstick/tests/unit/common/test_openstack_utils.py
parent346a2660b24ff3ca0128b0d873a716e735332a55 (diff)
Replace nova get server with shade client.
Rename get_server_by_name with get_server. Function get_server now uses shade client. JIRA: YARDSTICK-1088 Change-Id: I69c59145cefdb565f3ece27baaaf932905e1b757 Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/tests/unit/common/test_openstack_utils.py')
-rw-r--r--yardstick/tests/unit/common/test_openstack_utils.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py
index 3441ad264..89a810cf7 100644
--- a/yardstick/tests/unit/common/test_openstack_utils.py
+++ b/yardstick/tests/unit/common/test_openstack_utils.py
@@ -467,3 +467,25 @@ class AttachVolumeToServerTestCase(unittest.TestCase):
self.mock_shade_client, 'server_name_or_id', 'volume_name_or_id')
mock_logger.error.assert_called_once()
self.assertFalse(output)
+
+
+class GetServerTestCase(unittest.TestCase):
+
+ def test_get_server(self):
+ self.mock_shade_client = mock.Mock()
+ _uuid = uuidutils.generate_uuid()
+ self.mock_shade_client.get_server.return_value = {
+ 'name': 'server_name', 'id': _uuid}
+ output = openstack_utils.get_server(self.mock_shade_client,
+ 'server_name_or_id')
+ self.assertEqual({'name': 'server_name', 'id': _uuid}, output)
+
+ @mock.patch.object(openstack_utils, 'log')
+ def test_get_server_exception(self, mock_logger):
+ self.mock_shade_client = mock.Mock()
+ self.mock_shade_client.get_server.side_effect = (
+ exc.OpenStackCloudException('error message'))
+ output = openstack_utils.get_server(self.mock_shade_client,
+ 'server_name_or_id')
+ mock_logger.error.assert_called_once()
+ self.assertIsNone(output)