summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Walker (Daviey) <DaveWalker@ubuntu.com>2011-07-28 21:12:03 +0100
committerDave Walker (Daviey) <DaveWalker@ubuntu.com>2011-07-28 21:12:03 +0100
commit2e3b199005d16ee3e35cd6c71b8512628e3631bc (patch)
tree8cbb4784a04fa191a0aa693e7d738dd89be56dd0
parent25bd75bfd2c72899bf139e671fd42fd2dc1dc0e1 (diff)
Simplified test cases
-rw-r--r--nova/api/ec2/cloud.py2
-rw-r--r--nova/tests/test_api.py27
2 files changed, 7 insertions, 22 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index ecdbad895..371837d19 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -695,7 +695,7 @@ class CloudController(object):
if not re.match('^[a-zA-Z0-9_\- ]+$', str(group_name)):
# Some validation to ensure that values match API spec.
# - Alphanumeric characters, spaces, dashes, and underscores.
- # TODO(Daviey): LP: #813685 extend beyond group_name checking, and
+ # TODO(Daviey): LP: #813685 extend beyond group_name checking, and
# probably create a param validator that can be used elsewhere.
err = _("Value (%s) for parameter GroupName is invalid."
" Content limited to Alphanumeric characters, "
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py
index 5759e7726..40e62ac76 100644
--- a/nova/tests/test_api.py
+++ b/nova/tests/test_api.py
@@ -365,7 +365,7 @@ class ApiEc2TestCase(test.TestCase):
def test_group_name_valid_chars_security_group(self):
""" Test that we sanely handle invalid security group names.
- API Spec states we should only accept alphanumeric characters,
+ API Spec states we should only accept alphanumeric characters,
spaces, dashes, and underscores. """
self.expect_http()
self.mox.ReplayAll()
@@ -380,16 +380,8 @@ class ApiEc2TestCase(test.TestCase):
# dashes, and underscores.
security_group_name = "aa #^% -=99"
- try:
- self.ec2.create_security_group(security_group_name, 'test group')
- except EC2ResponseError, e:
- if e.code == 'InvalidParameterValue':
- pass
- else:
- self.fail("Unexpected EC2ResponseError: %s "
- "(expected InvalidParameterValue)" % e.code)
- else:
- self.fail('Exception not raised.')
+ self.assertRaises(EC2ResponseError, self.ec2.create_security_group,
+ security_group_name, 'test group')
def test_group_name_valid_length_security_group(self):
"""Test that we sanely handle invalid security group names.
@@ -406,16 +398,9 @@ class ApiEc2TestCase(test.TestCase):
# Test block group_name > 255 chars
security_group_name = "".join(random.choice("poiuytrewqasdfghjklmnbvc")
for x in range(random.randint(256, 266)))
- try:
- self.ec2.create_security_group(security_group_name, 'test group')
- except EC2ResponseError, e:
- if e.code == 'InvalidParameterValue':
- pass
- else:
- self.fail("Unexpected EC2ResponseError: %s "
- "(expected InvalidParameterValue)" % e.code)
- else:
- self.fail('Exception not raised.')
+
+ self.assertRaises(EC2ResponseError, self.ec2.create_security_group,
+ security_group_name, 'test group')
def test_authorize_revoke_security_group_cidr(self):
"""