Adds tests for attribute._validate_uuid
Removed redundant condition in _validate_uuid logic Wrote test cases accordingly Change-Id: I6ee83bda90cdfeaeaa17da6241f2673d0959baa2
This commit is contained in:
parent
cf79fd37a4
commit
cd1dfc2ce7
@ -246,10 +246,8 @@ def _validate_regex(data, valid_values=None):
|
||||
|
||||
|
||||
def _validate_uuid(data, valid_values=None):
|
||||
if uuidutils.is_uuid_like(data):
|
||||
return
|
||||
else:
|
||||
msg = _("%s is not a valid UUID") % data
|
||||
if not uuidutils.is_uuid_like(data):
|
||||
msg = _("'%s' is not a valid UUID") % data
|
||||
LOG.debug("validate_uuid: %s", msg)
|
||||
return msg
|
||||
|
||||
|
@ -255,6 +255,13 @@ class TestAttributes(unittest2.TestCase):
|
||||
error = "'%s' is not a valid IP subnet" % cidr
|
||||
self.assertEquals(msg, error)
|
||||
|
||||
def test_uuid(self):
|
||||
msg = attributes._validate_uuid('true')
|
||||
self.assertEquals(msg, "'true' is not a valid UUID")
|
||||
|
||||
msg = attributes._validate_uuid('00000000-ffff-ffff-ffff-000000000000')
|
||||
self.assertIsNone(msg)
|
||||
|
||||
|
||||
class TestConvertToBoolean(unittest2.TestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user