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:
Cedric Brandily 2014-12-26 16:22:24 +01:00
parent 2081aa9cde
commit 626368a9a9
2 changed files with 5 additions and 1 deletions

View File

@ -28,7 +28,8 @@ def _format_uuid_string(string):
return (string.replace('urn:', '')
.replace('uuid:', '')
.strip('{}')
.replace('-', ''))
.replace('-', '')
.lower())
def is_uuid_like(val):

View File

@ -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))