Adding basic validation of volume size on creation, plus tests for it.

This commit is contained in:
Joshua McKenty
2010-06-24 04:11:56 +01:00
committed by andy
parent bf64364d25
commit c87bcc8eae
2 changed files with 11 additions and 4 deletions

View File

@@ -59,6 +59,13 @@ class StorageTestCase(test.TrialTestCase):
self.assertRaises(exception.Error,
storage.get_volume,
volume_id)
def test_too_big_volume(self):
vol_size = '1001'
user_id = 'fake'
self.assertRaises(TypeError,
self.mystorage.create_volume,
vol_size, user_id)
def test_run_attach_detach_volume(self):
# Create one volume and one node to test with

View File

@@ -35,7 +35,7 @@ def rangetest(**argchecks): # validate ranges for both+defaults
# for all args to be checked
if argname in kargs:
# was passed by name
if kargs[argname] < low or kargs[argname] > high:
if float(kargs[argname]) < low or float(kargs[argname]) > high:
errmsg = '{0} argument "{1}" not in {2}..{3}'
errmsg = errmsg.format(funcname, argname, low, high)
raise TypeError(errmsg)
@@ -43,9 +43,9 @@ def rangetest(**argchecks): # validate ranges for both+defaults
elif argname in positionals:
# was passed by position
position = positionals.index(argname)
if pargs[position] < low or pargs[position] > high:
errmsg = '{0} argument "{1}" not in {2}..{3}'
errmsg = errmsg.format(funcname, argname, low, high)
if float(pargs[position]) < low or float(pargs[position]) > high:
errmsg = '{0} argument "{1}" with value of {4} not in {2}..{3}'
errmsg = errmsg.format(funcname, argname, low, high, pargs[position])
raise TypeError(errmsg)
else:
pass