diff --git a/neutron_lib/api/validators.py b/neutron_lib/api/validators.py index 50d31401e..2483fa289 100644 --- a/neutron_lib/api/validators.py +++ b/neutron_lib/api/validators.py @@ -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): diff --git a/neutron_lib/tests/unit/api/test_validators.py b/neutron_lib/tests/unit/api/test_validators.py index 0d80fd6e7..64f0b4c01 100644 --- a/neutron_lib/tests/unit/api/test_validators.py +++ b/neutron_lib/tests/unit/api/test_validators.py @@ -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,