diff options
| author | Michael Basnight <mbasnight@gmail.com> | 2013-06-17 23:34:27 -0700 |
|---|---|---|
| committer | Michael Basnight <mbasnight@gmail.com> | 2013-06-21 20:15:23 +0000 |
| commit | 9916c8f2733b683d859770d05dacd2c9c82912d7 (patch) | |
| tree | 084a0d53580cbbd34ed8f28de9302d6c78f7050d /reddwarfclient/tests/test_secgroups.py | |
| parent | bc90b3e088d3d4b83b5b3de0f9f83d9b6956947d (diff) | |
| download | python-troveclient-0.1.3.tar.gz | |
Rename from reddwarf to trove.0.1.3
Implements Blueprint reddwarf-trove-rename
Change-Id: Ib2d694c7466887ca297bea4250eca17cdc06b7bf
Diffstat (limited to 'reddwarfclient/tests/test_secgroups.py')
| -rw-r--r-- | reddwarfclient/tests/test_secgroups.py | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/reddwarfclient/tests/test_secgroups.py b/reddwarfclient/tests/test_secgroups.py deleted file mode 100644 index 25b4de8..0000000 --- a/reddwarfclient/tests/test_secgroups.py +++ /dev/null @@ -1,102 +0,0 @@ -from testtools import TestCase -from mock import Mock - -from reddwarfclient import security_groups -from reddwarfclient import base - -""" -Unit tests for security_groups.py -""" - - -class SecGroupTest(TestCase): - - def setUp(self): - super(SecGroupTest, self).setUp() - self.orig__init = security_groups.SecurityGroup.__init__ - security_groups.SecurityGroup.__init__ = Mock(return_value=None) - self.security_group = security_groups.SecurityGroup() - self.security_groups = security_groups.SecurityGroups(1) - - def tearDown(self): - super(SecGroupTest, self).tearDown() - security_groups.SecurityGroup.__init__ = self.orig__init - - def test___repr__(self): - self.security_group.name = "security_group-1" - self.assertEqual('<SecurityGroup: security_group-1>', - self.security_group.__repr__()) - - def test_list(self): - sec_group_list = ['secgroup1', 'secgroup2'] - self.security_groups.list = Mock(return_value=sec_group_list) - self.assertEqual(sec_group_list, self.security_groups.list()) - - def test_get(self): - def side_effect_func(path, inst): - return path, inst - - self.security_groups._get = Mock(side_effect=side_effect_func) - self.security_group.id = 1 - self.assertEqual(('/security-groups/1', 'security_group'), - self.security_groups.get(self.security_group)) - - -class SecGroupRuleTest(TestCase): - - def setUp(self): - super(SecGroupRuleTest, self).setUp() - self.orig__init = security_groups.SecurityGroupRule.__init__ - security_groups.SecurityGroupRule.__init__ = Mock(return_value=None) - security_groups.SecurityGroupRules.__init__ = Mock(return_value=None) - self.security_group_rule = security_groups.SecurityGroupRule() - self.security_group_rules = security_groups.SecurityGroupRules() - - def tearDown(self): - super(SecGroupRuleTest, self).tearDown() - security_groups.SecurityGroupRule.__init__ = self.orig__init - - def test___repr__(self): - self.security_group_rule.group_id = 1 - self.security_group_rule.protocol = "tcp" - self.security_group_rule.from_port = 80 - self.security_group_rule.to_port = 80 - self.security_group_rule.cidr = "0.0.0.0//0" - representation = \ - "<SecurityGroupRule: ( \ - Security Group id: %d, \ - Protocol: %s, \ - From_Port: %d, \ - To_Port: %d, \ - CIDR: %s )>" % (1, "tcp", 80, 80, "0.0.0.0//0") - - self.assertEqual(representation, - self.security_group_rule.__repr__()) - - def test_create(self): - def side_effect_func(path, body, inst): - return path, body, inst - - self.security_group_rules._create = Mock(side_effect=side_effect_func) - p, b, i = self.security_group_rules.create(1, "tcp", - 80, 80, "0.0.0.0//0") - self.assertEqual("/security-group-rules", p) - self.assertEqual("security_group_rule", i) - self.assertEqual(1, b["security_group_rule"]["group_id"]) - self.assertEqual("tcp", b["security_group_rule"]["protocol"]) - self.assertEqual(80, b["security_group_rule"]["from_port"]) - self.assertEqual(80, b["security_group_rule"]["to_port"]) - self.assertEqual("0.0.0.0//0", b["security_group_rule"]["cidr"]) - - def test_delete(self): - resp = Mock() - resp.status = 200 - body = None - self.security_group_rules.api = Mock() - self.security_group_rules.api.client = Mock() - self.security_group_rules.api.client.delete = \ - Mock(return_value=(resp, body)) - self.security_group_rules.delete(self.id) - resp.status = 500 - self.assertRaises(ValueError, self.security_group_rules.delete, - self.id) |
