diff options
author | Rex Lee <limingjiang@huawei.com> | 2018-03-28 00:15:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-03-28 00:15:36 +0000 |
commit | 5293564955b96ff3973f498b1f526e70e792b12b (patch) | |
tree | 1c71d226dab20818ba871cc37f3e78075d540bc9 /yardstick/tests | |
parent | 1b216da0fc7cd6ca6af9f23db7f404e42a6a6db6 (diff) | |
parent | 2d1118050034ecd38f73298498b72c2af7c3cc20 (diff) |
Merge "Replace neutron create security group rule with shade."
Diffstat (limited to 'yardstick/tests')
-rw-r--r-- | yardstick/tests/unit/common/test_openstack_utils.py | 25 |
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) |