Support non-lowercase uuids in is_uuid_like
According to RFC 4122 (on uuid), uuids are case insensitive but currently is_uuid_like returns False if the input is a non-lowercase string. This change adds non-lowercase uuid support in is_uuid_like. Change-Id: Ie017e183c3ee36b8dea9c1aa82cdb697c26bbf17 Closes-Bug: #1405624
This commit is contained in:
parent
2081aa9cde
commit
626368a9a9
@ -28,7 +28,8 @@ def _format_uuid_string(string):
|
||||
return (string.replace('urn:', '')
|
||||
.replace('uuid:', '')
|
||||
.strip('{}')
|
||||
.replace('-', ''))
|
||||
.replace('-', '')
|
||||
.lower())
|
||||
|
||||
|
||||
def is_uuid_like(val):
|
||||
|
@ -44,6 +44,9 @@ class UUIDUtilsTest(test_base.BaseTestCase):
|
||||
self.assertTrue(uuidutils.is_uuid_like(
|
||||
'{}---bbb---aaa--aaa--aaa-----aaa---aaa--bbb-bbb---bbb-bbb-bb-{}'))
|
||||
|
||||
def test_is_uuid_like_insensitive(self):
|
||||
self.assertTrue(uuidutils.is_uuid_like(str(uuid.uuid4()).upper()))
|
||||
|
||||
def test_id_is_uuid_like(self):
|
||||
self.assertFalse(uuidutils.is_uuid_like(1234567))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user