Merge "Add to_dict method to Resource class"
This commit is contained in:
commit
7476dbd8dc
@ -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)
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user