Merge "Refactor TestVolumeList with FakeVolume"
This commit is contained in:
commit
e1c53250bc
@ -391,6 +391,8 @@ class FakeVolume(object):
|
|||||||
'size': random.randint(1, 20),
|
'size': random.randint(1, 20),
|
||||||
'volume_type':
|
'volume_type':
|
||||||
random.choice(['fake_lvmdriver-1', 'fake_lvmdriver-2']),
|
random.choice(['fake_lvmdriver-1', 'fake_lvmdriver-2']),
|
||||||
|
'bootable':
|
||||||
|
random.randint(0, 1),
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
||||||
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
|
||||||
|
@ -58,6 +58,7 @@ class TestVolumeCreate(TestVolume):
|
|||||||
columns = (
|
columns = (
|
||||||
'attachments',
|
'attachments',
|
||||||
'availability_zone',
|
'availability_zone',
|
||||||
|
'bootable',
|
||||||
'description',
|
'description',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
@ -77,6 +78,7 @@ class TestVolumeCreate(TestVolume):
|
|||||||
self.datalist = (
|
self.datalist = (
|
||||||
self.new_volume.attachments,
|
self.new_volume.attachments,
|
||||||
self.new_volume.availability_zone,
|
self.new_volume.availability_zone,
|
||||||
|
self.new_volume.bootable,
|
||||||
self.new_volume.description,
|
self.new_volume.description,
|
||||||
self.new_volume.id,
|
self.new_volume.id,
|
||||||
self.new_volume.name,
|
self.new_volume.name,
|
||||||
@ -475,13 +477,8 @@ class TestVolumeList(TestVolume):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestVolumeList, self).setUp()
|
super(TestVolumeList, self).setUp()
|
||||||
|
|
||||||
self.volumes_mock.list.return_value = [
|
self.mock_volume = volume_fakes.FakeVolume.create_one_volume()
|
||||||
fakes.FakeResource(
|
self.volumes_mock.list.return_value = [self.mock_volume]
|
||||||
None,
|
|
||||||
copy.deepcopy(volume_fakes.VOLUME),
|
|
||||||
loaded=True,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
self.users_mock.get.return_value = [
|
self.users_mock.get.return_value = [
|
||||||
fakes.FakeResource(
|
fakes.FakeResource(
|
||||||
@ -516,14 +513,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -544,14 +541,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -574,14 +571,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -601,14 +598,14 @@ class TestVolumeList(TestVolume):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -631,14 +628,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -659,14 +656,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -687,14 +684,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -715,14 +712,14 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
msg,
|
msg,
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
@ -754,18 +751,18 @@ class TestVolumeList(TestVolume):
|
|||||||
]
|
]
|
||||||
self.assertEqual(collist, columns)
|
self.assertEqual(collist, columns)
|
||||||
|
|
||||||
server = volume_fakes.volume_attachment_server['server_id']
|
server = self.mock_volume.attachments[0]['server_id']
|
||||||
device = volume_fakes.volume_attachment_server['device']
|
device = self.mock_volume.attachments[0]['device']
|
||||||
msg = 'Attached to %s on %s ' % (server, device)
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self.mock_volume.id,
|
||||||
volume_fakes.volume_name,
|
self.mock_volume.name,
|
||||||
volume_fakes.volume_status,
|
self.mock_volume.status,
|
||||||
volume_fakes.volume_size,
|
self.mock_volume.size,
|
||||||
volume_fakes.volume_type,
|
self.mock_volume.volume_type,
|
||||||
'',
|
self.mock_volume.bootable,
|
||||||
msg,
|
msg,
|
||||||
"Alpha='a', Beta='b', Gamma='g'",
|
utils.format_dict(self.mock_volume.metadata),
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user