Adding basic validation of volume size on creation, plus tests for it.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user