aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/common/test_openstack_utils.py
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-02-23 14:59:09 +0000
committerShobhi Jain <shobhi.jain@intel.com>2018-03-20 17:32:26 +0000
commit221da2200131f617d36f3143e730f9dcfab530d0 (patch)
tree32ded0b52954b921ba074a5fbdb65deec6f0c5ae /yardstick/tests/unit/common/test_openstack_utils.py
parent68c934be759962d18d109fde35726f416088a126 (diff)
Replace neutron floating ip creation with shade.
Function create_floating_ip now uses shade client instead of neutron client. JIRA: YARDSTICK-890 Change-Id: I3defd691dad998cebf98442b52f0555b176f1af4 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.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py
index 640d2d2c9..eb96aef84 100644
--- a/yardstick/tests/unit/common/test_openstack_utils.py
+++ b/yardstick/tests/unit/common/test_openstack_utils.py
@@ -35,28 +35,6 @@ class GetHeatApiVersionTestCase(unittest.TestCase):
self.assertEqual(api_version, expected_result)
-class GetNetworkIdTestCase(unittest.TestCase):
-
- def test_get_network_id(self):
- _uuid = uuidutils.generate_uuid()
- mock_shade_client = mock.Mock()
- mock_shade_client.list_networks = mock.Mock()
- mock_shade_client.list_networks.return_value = [{'id': _uuid}]
-
- output = openstack_utils.get_network_id(mock_shade_client,
- 'network_name')
- self.assertEqual(_uuid, output)
-
- def test_get_network_id_no_network(self):
- mock_shade_client = mock.Mock()
- mock_shade_client.list_networks = mock.Mock()
- mock_shade_client.list_networks.return_value = None
-
- output = openstack_utils.get_network_id(mock_shade_client,
- 'network_name')
- self.assertIsNone(output)
-
-
class DeleteNeutronNetTestCase(unittest.TestCase):
def setUp(self):
@@ -208,3 +186,27 @@ class RemoveRouterInterfaceTestCase(unittest.TestCase):
self.mock_shade_client, self.router)
mock_logger.error.assert_called_once()
self.assertFalse(output)
+
+
+class CreateFloatingIpTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.mock_shade_client = mock.Mock()
+ self.network_name_or_id = 'name'
+ self.mock_shade_client.create_floating_ip = mock.Mock()
+
+ def test_create_floating_ip(self):
+ self.mock_shade_client.create_floating_ip.return_value = \
+ {'floating_ip_address': 'value1', 'id': 'value2'}
+ output = openstack_utils.create_floating_ip(self.mock_shade_client,
+ self.network_name_or_id)
+ self.assertEqual({'fip_addr': 'value1', 'fip_id': 'value2'}, output)
+
+ @mock.patch.object(openstack_utils, 'log')
+ def test_create_floating_ip_exception(self, mock_logger):
+ self.mock_shade_client.create_floating_ip.side_effect = (
+ exc.OpenStackCloudException('error message'))
+ output = openstack_utils.create_floating_ip(
+ self.mock_shade_client, self.network_name_or_id)
+ mock_logger.error.assert_called_once()
+ self.assertIsNone(output)