Merge "Add to_dict method to Resource class"

This commit is contained in:
Jenkins 2016-01-05 21:15:49 +00:00 committed by Gerrit Code Review
commit 7476dbd8dc
2 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,7 @@ Base utilities to build API operation managers and objects on top of.
# pylint: disable=E1102
import abc
import copy
import six
from six.moves.urllib import parse
@ -489,3 +490,6 @@ class Resource(object):
def set_loaded(self, val):
self._loaded = val
def to_dict(self):
return copy.deepcopy(self._info)

View File

@ -59,3 +59,7 @@ class BaseTest(utils.TestCase):
self.assertRaises(exceptions.NotFound,
cs.volumes.find,
vegetable='carrot')
def test_to_dict(self):
r1 = base.Resource(None, {'id': 1, 'name': 'hi'})
self.assertEqual({'id': 1, 'name': 'hi'}, r1.to_dict())