make sure .get() also updates _info
Having the _info get out of sync with the actual attributes is kind of a trap for the unwary. _info is used in preference to the attributes in many places, and letting it get out of sync means that the method of retrieval (get() vs. list()) influences the result. Change-Id: I9d9bf086fa790b811c520b2fa317f95cb1921805
This commit is contained in:
parent
5f3dbfdfdd
commit
2a495c03d5
@ -313,6 +313,7 @@ class Resource(object):
|
||||
for (k, v) in info.iteritems():
|
||||
try:
|
||||
setattr(self, k, v)
|
||||
self._info[k] = v
|
||||
except AttributeError:
|
||||
# In this case we already defined the attribute on the class
|
||||
pass
|
||||
|
@ -32,6 +32,13 @@ class ServersTest(utils.TestCase):
|
||||
self.assertEqual(s.id, 1234)
|
||||
self.assertEqual(s.status, 'BUILD')
|
||||
|
||||
def test_get_server_promote_details(self):
|
||||
s1 = cs.servers.list(detailed=False)[0]
|
||||
s2 = cs.servers.list(detailed=True)[0]
|
||||
self.assertNotEquals(s1._info, s2._info)
|
||||
s1.get()
|
||||
self.assertEquals(s1._info, s2._info)
|
||||
|
||||
def test_create_server(self):
|
||||
s = cs.servers.create(
|
||||
name="My server",
|
||||
|
Loading…
x
Reference in New Issue
Block a user