diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-03-14 11:53:06 +0000 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-03-27 16:46:49 +0000 |
commit | 2d1118050034ecd38f73298498b72c2af7c3cc20 (patch) | |
tree | d26091f26dfeb5ab1f3e01954d67fefee659773d /yardstick/tests | |
parent | 06f089db5fa9de1fd05e37122afad6555d50265d (diff) |
Replace neutron create security group rule with shade.
Rename create_secgroup_rule with create_security_group_rule.
Function create_security_group_rule now uses shade client.
JIRA: YARDSTICK-890
Change-Id: Ie0ebac67a281e55dc95c0e3e33ba43de80aba9ec
Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
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) |