aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/common
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2018-03-21 08:13:02 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-03-21 08:13:02 +0000
commita854a1dde960b630c0c0d854dee9232e4c4e9ac8 (patch)
tree731a85dbebaae7b8e5ece8559e58eec512b3d19d /yardstick/tests/unit/common
parentc4228f65829e86abadb7d93246d0b6de9dab2d51 (diff)
parent16aa0b60244b742c2b6478cea93b1eebce4c335f (diff)
Merge "Replace neutron router creation with shade."
Diffstat (limited to 'yardstick/tests/unit/common')
-rw-r--r--yardstick/tests/unit/common/test_openstack_utils.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py
index c6b0f46b2..e39a13f1b 100644
--- a/yardstick/tests/unit/common/test_openstack_utils.py
+++ b/yardstick/tests/unit/common/test_openstack_utils.py
@@ -161,3 +161,27 @@ class DeleteNeutronRouterTestCase(unittest.TestCase):
'router_id')
mock_logger.error.assert_called_once()
self.assertFalse(output)
+
+
+class CreateNeutronRouterTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.mock_shade_client = mock.Mock()
+ self.mock_shade_client.create_subnet = mock.Mock()
+
+ def test_create_neutron_router(self):
+ _uuid = uuidutils.generate_uuid()
+ self.mock_shade_client.create_router.return_value = {'id': _uuid}
+ output = openstack_utils.create_neutron_router(
+ self.mock_shade_client)
+ self.assertEqual(_uuid, output)
+
+ @mock.patch.object(openstack_utils, 'log')
+ def test_create_neutron_subnet_exception(self, mock_logger):
+ self.mock_shade_client.create_router.side_effect = (
+ exc.OpenStackCloudException('error message'))
+
+ output = openstack_utils.create_neutron_router(
+ self.mock_shade_client)
+ mock_logger.error.assert_called_once()
+ self.assertIsNone(output)