Fix regression in validate_uuid_list()

Change https://review.openstack.org/358088 broke validate_uuid_list()
by not including the valid_values parameter.

Closes-Bug: #1620841

Change-Id: Ic75f4d1319bb88a9e4f9e4699575ce8e75829841
This commit is contained in:
Henry Gessau 2016-09-06 18:22:34 -04:00
parent 30f5a5c497
commit 3d043c0ebc
2 changed files with 18 additions and 2 deletions

View File

@ -649,14 +649,15 @@ _validate_uuid_list = functools.partial(_validate_list_of_items,
# NOTE(boden): subbed out for docstring comments.
def validate_uuid_list(data):
def validate_uuid_list(data, valid_values=None):
"""Validate data is a list of UUID like values.
:param data: The data to validate.
:param valid_values: Not used!
:returns: None if data is an iterable that contains valid UUID values,
otherwise a message is returned indicating why validation failed.
"""
return _validate_uuid_list(data)
return _validate_uuid_list(data, valid_values)
def _validate_dict_item(key, key_validator, data):

View File

@ -738,6 +738,21 @@ class TestAttributeValidation(base.BaseTestCase):
msg = validators.validate_uuid('00000000-ffff-ffff-ffff-000000000000')
self.assertIsNone(msg)
def test_validate_uuid_list(self):
bad_uuid_list = ['00000000-ffff-ffff-ffff-000000000000',
'00000000-ffff-ffff-ffff-000000000001',
'123']
msg = validators.validate_uuid_list(bad_uuid_list,
valid_values='parameter not used')
error = "'%s' is not a valid UUID" % bad_uuid_list[2]
self.assertEqual(error, msg)
good_uuid_list = ['00000000-ffff-ffff-ffff-000000000000',
'00000000-ffff-ffff-ffff-000000000001']
msg = validators.validate_uuid_list(good_uuid_list,
valid_values='parameter not used')
self.assertIsNone(msg)
def test__validate_list_of_items(self):
# check not a list
items = [None,