Make __repr__ print encryption_id for VolumeEncryptionType class
The self.name attribute is undefined in the VolumeEncryptionType class. Instead we should print the self.encryption_id attribute in the __repr__(). Change-Id: Ic11b45069145bbae078c8175928c5dd869bd8cb8 Partial-Bug: #1585024
This commit is contained in:
parent
df81163fce
commit
906c9986a7
@ -19,6 +19,13 @@ from cinderclient.tests.unit.v1 import fakes
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
||||
FAKE_ENCRY_TYPE = {'provider': 'Test',
|
||||
'key_size': None,
|
||||
'cipher': None,
|
||||
'control_location': None,
|
||||
'volume_type_id': '65922555-7bc0-47e9-8d88-c7fdbcac4781',
|
||||
'encryption_id': '62daf814-cf9b-401c-8fc8-f84d7850fb7c'}
|
||||
|
||||
|
||||
class VolumeEncryptionTypesTest(utils.TestCase):
|
||||
"""
|
||||
@ -98,3 +105,14 @@ class VolumeEncryptionTypesTest(utils.TestCase):
|
||||
cs.assert_called('DELETE', '/types/1/encryption/provider')
|
||||
self.assertIsInstance(result, tuple)
|
||||
self.assertEqual(202, result[0].status_code)
|
||||
|
||||
def test___repr__(self):
|
||||
"""
|
||||
Unit test for VolumeEncryptionTypes.__repr__
|
||||
|
||||
Verify that one encryption type can be printed
|
||||
"""
|
||||
encry_type = VolumeEncryptionType(None, FAKE_ENCRY_TYPE)
|
||||
self.assertEqual(
|
||||
"<VolumeEncryptionType: %s>" % FAKE_ENCRY_TYPE['encryption_id'],
|
||||
repr(encry_type))
|
||||
|
@ -19,6 +19,13 @@ from cinderclient.tests.unit.v2 import fakes
|
||||
|
||||
cs = fakes.FakeClient()
|
||||
|
||||
FAKE_ENCRY_TYPE = {'provider': 'Test',
|
||||
'key_size': None,
|
||||
'cipher': None,
|
||||
'control_location': None,
|
||||
'volume_type_id': '65922555-7bc0-47e9-8d88-c7fdbcac4781',
|
||||
'encryption_id': '62daf814-cf9b-401c-8fc8-f84d7850fb7c'}
|
||||
|
||||
|
||||
class VolumeEncryptionTypesTest(utils.TestCase):
|
||||
"""
|
||||
@ -114,3 +121,14 @@ class VolumeEncryptionTypesTest(utils.TestCase):
|
||||
self.assertIsInstance(result, tuple)
|
||||
self.assertEqual(202, result[0].status_code)
|
||||
self._assert_request_id(result)
|
||||
|
||||
def test___repr__(self):
|
||||
"""
|
||||
Unit test for VolumeEncryptionTypes.__repr__
|
||||
|
||||
Verify that one encryption type can be printed
|
||||
"""
|
||||
encry_type = VolumeEncryptionType(None, FAKE_ENCRY_TYPE)
|
||||
self.assertEqual(
|
||||
"<VolumeEncryptionType: %s>" % FAKE_ENCRY_TYPE['encryption_id'],
|
||||
repr(encry_type))
|
||||
|
@ -27,7 +27,7 @@ class VolumeEncryptionType(base.Resource):
|
||||
encryption for a specific volume type.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "<VolumeEncryptionType: %s>" % self.name
|
||||
return "<VolumeEncryptionType: %s>" % self.encryption_id
|
||||
|
||||
|
||||
class VolumeEncryptionTypeManager(base.ManagerWithFind):
|
||||
|
@ -28,7 +28,7 @@ class VolumeEncryptionType(base.Resource):
|
||||
encryption for a specific volume type.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "<VolumeEncryptionType: %s>" % self.name
|
||||
return "<VolumeEncryptionType: %s>" % self.encryption_id
|
||||
|
||||
|
||||
class VolumeEncryptionTypeManager(base.ManagerWithFind):
|
||||
|
Loading…
Reference in New Issue
Block a user