Merge "Raise on NodeManager get when invalid identifier provided"
This commit is contained in:
@@ -72,8 +72,14 @@ class Manager(object):
|
||||
|
||||
:param resource_id: Identifier of the resource.
|
||||
:param fields: List of specific fields to be returned.
|
||||
:raises exc.ValidationError: For invalid resource_id arg value.
|
||||
"""
|
||||
|
||||
if not resource_id:
|
||||
raise exc.ValidationError(
|
||||
"The identifier argument is invalid. "
|
||||
"Value provided: {!r}".format(resource_id))
|
||||
|
||||
if fields is not None:
|
||||
resource_id = '%s?fields=' % resource_id
|
||||
resource_id += ','.join(fields)
|
||||
|
@@ -131,6 +131,12 @@ class ManagerTestCase(testtools.TestCase):
|
||||
self.assertEqual(resource_id, resource.uuid)
|
||||
self.assertEqual(TESTABLE_RESOURCE['attribute1'], resource.attribute1)
|
||||
|
||||
def test__get_invalid_resource_id_raises(self):
|
||||
resource_ids = [[], {}, False, '', 0, None, ()]
|
||||
for resource_id in resource_ids:
|
||||
self.assertRaises(exc.ValidationError, self.manager._get,
|
||||
resource_id=resource_id)
|
||||
|
||||
def test__get_as_dict(self):
|
||||
resource_id = TESTABLE_RESOURCE['uuid']
|
||||
resource = self.manager._get_as_dict(resource_id)
|
||||
|
Reference in New Issue
Block a user