summaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/common/test_openstack_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/tests/unit/common/test_openstack_utils.py')
-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 b8f85c083..3b7e8eaa1 100644
--- a/yardstick/tests/unit/common/test_openstack_utils.py
+++ b/yardstick/tests/unit/common/test_openstack_utils.py
@@ -239,3 +239,28 @@ class DeleteFloatingIpTestCase(unittest.TestCase):
'floating_ip_id')
mock_logger.error.assert_called_once()
self.assertFalse(output)
+
+
+class CreateSecurityGroupRuleTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.mock_shade_client = mock.Mock()
+ self.secgroup_name_or_id = 'sg_name_id'
+ self.mock_shade_client.create_security_group_rule = mock.Mock()
+
+ def test_create_security_group_rule(self):
+ self.mock_shade_client.create_security_group_rule.return_value = (
+ {'security_group_rule'})
+ output = openstack_utils.create_security_group_rule(
+ self.mock_shade_client, self.secgroup_name_or_id)
+ self.assertTrue(output)
+
+ @mock.patch.object(openstack_utils, 'log')
+ def test_create_security_group_rule_exception(self, mock_logger):
+ self.mock_shade_client.create_security_group_rule.side_effect = (
+ exc.OpenStackCloudException('error message'))
+
+ output = openstack_utils.create_security_group_rule(
+ self.mock_shade_client, self.secgroup_name_or_id)
+ mock_logger.error.assert_called_once()
+ self.assertFalse(output)