aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/common
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-02-07 11:08:05 +0000
committerShobhi Jain <shobhi.jain@intel.com>2018-03-12 10:55:12 +0000
commit9f26e65c62fd5a4a1fbf9048e3bfe857b18729c9 (patch)
tree54c3443c0cc0160a88078735b76f673e2e7b456a /yardstick/tests/unit/common
parent5bb06d8977dc1ffa18c47cd1b152f84f4a6cfa34 (diff)
Replace neutron subnet creation with shade.
Function 'create_neutron_subnet' now uses shade client instead of neutron client. JIRA: YARDSTICK-890 Change-Id: I8eb5295cecd73742bfb5a7d0764af6f45ef0685e Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/tests/unit/common')
-rw-r--r--yardstick/tests/unit/common/test_openstack_utils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py
index a63661025..cf5c206a5 100644
--- a/yardstick/tests/unit/common/test_openstack_utils.py
+++ b/yardstick/tests/unit/common/test_openstack_utils.py
@@ -108,3 +108,28 @@ class CreateNeutronNetTestCase(unittest.TestCase):
self.network_name)
mock_logger.error.assert_called_once()
self.assertIsNone(output)
+
+
+class CreateNeutronSubnetTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.mock_shade_client = mock.Mock()
+ self.network_name_or_id = 'name_or_id'
+ self.mock_shade_client.create_subnet = mock.Mock()
+
+ def test_create_neutron_subnet(self):
+ _uuid = uuidutils.generate_uuid()
+ self.mock_shade_client.create_subnet.return_value = {'id': _uuid}
+ output = openstack_utils.create_neutron_subnet(
+ self.mock_shade_client, self.network_name_or_id)
+ self.assertEqual(_uuid, output)
+
+ @mock.patch.object(openstack_utils, 'log')
+ def test_create_neutron_subnet_exception(self, mock_logger):
+ self.mock_shade_client.create_subnet.side_effect = (
+ exc.OpenStackCloudException('error message'))
+
+ output = openstack_utils.create_neutron_subnet(
+ self.mock_shade_client, self.network_name_or_id)
+ mock_logger.error.assert_called_once()
+ self.assertIsNone(output)