Merge "Adds tests for attribute._validate_uuid"

This commit is contained in:
Jenkins 2012-11-12 18:35:18 +00:00 committed by Gerrit Code Review
commit 44005fea88
2 changed files with 9 additions and 4 deletions

View File

@ -242,10 +242,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

View File

@ -302,6 +302,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):