Fixing flavor access __repr__ method
The Flavor Access __repr__ method was crashing because it was using a non-existing attribute called "name". On this fix, this method will now return the following: <FlavorAccess flavor id: {flavor_id}, tenant id: {tenant_id}> Closes-bug: #1331602 Change-Id: Ia2c24312e59e6c0aba1009766a15d390dc2721b1
This commit is contained in:
parent
d46e206ba3
commit
465d383471
@ -56,3 +56,15 @@ class FlavorAccessTest(utils.TestCase):
|
||||
|
||||
cs.assert_called('POST', '/flavors/2/action', body)
|
||||
[self.assertIsInstance(a, flavor_access.FlavorAccess) for a in r]
|
||||
|
||||
def test_repr_flavor_access(self):
|
||||
flavor = cs.flavors.get(2)
|
||||
tenant = 'proj3'
|
||||
r = cs.flavor_access.add_tenant_access(flavor, tenant)
|
||||
|
||||
def get_expected(flavor_access):
|
||||
return ("<FlavorAccess flavor id: %s, tenant id: %s>" %
|
||||
(flavor_access.flavor_id, flavor_access.tenant_id))
|
||||
|
||||
for a in r:
|
||||
self.assertEqual(get_expected(a), repr(a))
|
||||
|
@ -21,7 +21,8 @@ from novaclient.openstack.common.gettextutils import _
|
||||
|
||||
class FlavorAccess(base.Resource):
|
||||
def __repr__(self):
|
||||
return "<FlavorAccess: %s>" % self.name
|
||||
return ("<FlavorAccess flavor id: %s, tenant id: %s>" %
|
||||
(self.flavor_id, self.tenant_id))
|
||||
|
||||
|
||||
class FlavorAccessManager(base.ManagerWithFind):
|
||||
|
Loading…
Reference in New Issue
Block a user