Merge "Refactor volume unit test with FakeVolume class in volume v1"
This commit is contained in:
commit
0c6a46ab5c
@ -363,24 +363,24 @@ class FakeVolume(object):
|
|||||||
# Set default attribute
|
# Set default attribute
|
||||||
volume_info = {
|
volume_info = {
|
||||||
'id': 'volume-id' + uuid.uuid4().hex,
|
'id': 'volume-id' + uuid.uuid4().hex,
|
||||||
'name': 'volume-name' + uuid.uuid4().hex,
|
'display_name': 'volume-name' + uuid.uuid4().hex,
|
||||||
'description': 'description' + uuid.uuid4().hex,
|
'display_description': 'description' + uuid.uuid4().hex,
|
||||||
'status': random.choice(['available', 'in_use']),
|
'status': 'available',
|
||||||
'size': random.randint(1, 20),
|
'size': 10,
|
||||||
'volume_type':
|
'volume_type':
|
||||||
random.choice(['fake_lvmdriver-1', 'fake_lvmdriver-2']),
|
random.choice(['fake_lvmdriver-1', 'fake_lvmdriver-2']),
|
||||||
'bootable':
|
'bootable': 'true',
|
||||||
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,
|
||||||
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex},
|
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex},
|
||||||
'snapshot_id': random.randint(1, 5),
|
'snapshot_id': 'snapshot-id-' + uuid.uuid4().hex,
|
||||||
'availability_zone': 'zone' + uuid.uuid4().hex,
|
'availability_zone': 'zone' + uuid.uuid4().hex,
|
||||||
'attachments': [{
|
'attachments': [{
|
||||||
'device': '/dev/' + uuid.uuid4().hex,
|
'device': '/dev/' + uuid.uuid4().hex,
|
||||||
'server_id': uuid.uuid4().hex,
|
'server_id': uuid.uuid4().hex,
|
||||||
}, ],
|
}, ],
|
||||||
|
'created_at': 'time-' + uuid.uuid4().hex,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite default attributes if there are some attributes set
|
# Overwrite default attributes if there are some attributes set
|
||||||
|
@ -67,48 +67,50 @@ class TestVolumeCreate(TestVolume):
|
|||||||
user = identity_fakes.FakeUser.create_one_user()
|
user = identity_fakes.FakeUser.create_one_user()
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'attach_status',
|
'attachments',
|
||||||
'availability_zone',
|
'availability_zone',
|
||||||
|
'bootable',
|
||||||
|
'created_at',
|
||||||
'display_description',
|
'display_description',
|
||||||
'display_name',
|
'display_name',
|
||||||
'id',
|
'id',
|
||||||
'properties',
|
'properties',
|
||||||
'size',
|
'size',
|
||||||
|
'snapshot_id',
|
||||||
'status',
|
'status',
|
||||||
'type',
|
'type',
|
||||||
)
|
)
|
||||||
datalist = (
|
|
||||||
'detached',
|
|
||||||
volume_fakes.volume_zone,
|
|
||||||
volume_fakes.volume_description,
|
|
||||||
volume_fakes.volume_name,
|
|
||||||
volume_fakes.volume_id,
|
|
||||||
volume_fakes.volume_metadata_str,
|
|
||||||
volume_fakes.volume_size,
|
|
||||||
volume_fakes.volume_status,
|
|
||||||
volume_fakes.volume_type,
|
|
||||||
)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestVolumeCreate, self).setUp()
|
super(TestVolumeCreate, self).setUp()
|
||||||
|
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
|
||||||
self.volumes_mock.create.return_value = fakes.FakeResource(
|
self.datalist = (
|
||||||
None,
|
self.new_volume.attachments,
|
||||||
copy.deepcopy(volume_fakes.VOLUME),
|
self.new_volume.availability_zone,
|
||||||
loaded=True,
|
self.new_volume.bootable,
|
||||||
|
self.new_volume.created_at,
|
||||||
|
self.new_volume.display_description,
|
||||||
|
self.new_volume.display_name,
|
||||||
|
self.new_volume.id,
|
||||||
|
utils.format_dict(self.new_volume.metadata),
|
||||||
|
self.new_volume.size,
|
||||||
|
self.new_volume.snapshot_id,
|
||||||
|
self.new_volume.status,
|
||||||
|
self.new_volume.volume_type,
|
||||||
)
|
)
|
||||||
|
self.volumes_mock.create.return_value = self.new_volume
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = volume.CreateVolume(self.app, None)
|
self.cmd = volume.CreateVolume(self.app, None)
|
||||||
|
|
||||||
def test_volume_create_min_options(self):
|
def test_volume_create_min_options(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -123,10 +125,10 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -140,18 +142,18 @@ class TestVolumeCreate(TestVolume):
|
|||||||
|
|
||||||
def test_volume_create_options(self):
|
def test_volume_create_options(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
'--description', volume_fakes.volume_description,
|
'--description', self.new_volume.display_description,
|
||||||
'--type', volume_fakes.volume_type,
|
'--type', self.new_volume.volume_type,
|
||||||
'--availability-zone', volume_fakes.volume_zone,
|
'--availability-zone', self.new_volume.availability_zone,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('description', volume_fakes.volume_description),
|
('description', self.new_volume.display_description),
|
||||||
('type', volume_fakes.volume_type),
|
('type', self.new_volume.volume_type),
|
||||||
('availability_zone', volume_fakes.volume_zone),
|
('availability_zone', self.new_volume.availability_zone),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -166,15 +168,15 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
volume_fakes.volume_description,
|
self.new_volume.display_description,
|
||||||
volume_fakes.volume_type,
|
self.new_volume.volume_type,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_zone,
|
self.new_volume.availability_zone,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
@ -189,16 +191,16 @@ class TestVolumeCreate(TestVolume):
|
|||||||
self.users_mock.get.return_value = self.user
|
self.users_mock.get.return_value = self.user
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
'--project', self.project.id,
|
'--project', self.project.id,
|
||||||
'--user', self.user.id,
|
'--user', self.user.id,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('project', self.project.id),
|
('project', self.project.id),
|
||||||
('user', self.user.id),
|
('user', self.user.id),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -213,10 +215,10 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
self.user.id,
|
self.user.id,
|
||||||
@ -236,16 +238,16 @@ class TestVolumeCreate(TestVolume):
|
|||||||
self.users_mock.get.return_value = self.user
|
self.users_mock.get.return_value = self.user
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
'--project', self.project.name,
|
'--project', self.project.name,
|
||||||
'--user', self.user.name,
|
'--user', self.user.name,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('project', self.project.name),
|
('project', self.project.name),
|
||||||
('user', self.user.name),
|
('user', self.user.name),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -260,10 +262,10 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
self.user.id,
|
self.user.id,
|
||||||
@ -280,13 +282,13 @@ class TestVolumeCreate(TestVolume):
|
|||||||
arglist = [
|
arglist = [
|
||||||
'--property', 'Alpha=a',
|
'--property', 'Alpha=a',
|
||||||
'--property', 'Beta=b',
|
'--property', 'Beta=b',
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('property', {'Alpha': 'a', 'Beta': 'b'}),
|
('property', {'Alpha': 'a', 'Beta': 'b'}),
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -301,10 +303,10 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -326,13 +328,13 @@ class TestVolumeCreate(TestVolume):
|
|||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--image', volume_fakes.image_id,
|
'--image', volume_fakes.image_id,
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('image', volume_fakes.image_id),
|
('image', volume_fakes.image_id),
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -347,10 +349,10 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -372,13 +374,13 @@ class TestVolumeCreate(TestVolume):
|
|||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--image', volume_fakes.image_name,
|
'--image', volume_fakes.image_name,
|
||||||
'--size', str(volume_fakes.volume_size),
|
'--size', str(self.new_volume.size),
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('image', volume_fakes.image_name),
|
('image', volume_fakes.image_name),
|
||||||
('size', volume_fakes.volume_size),
|
('size', self.new_volume.size),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self.new_volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -393,10 +395,10 @@ class TestVolumeCreate(TestVolume):
|
|||||||
# project_id=, availability_zone=,
|
# project_id=, availability_zone=,
|
||||||
# metadata=, imageRef=)
|
# metadata=, imageRef=)
|
||||||
self.volumes_mock.create.assert_called_with(
|
self.volumes_mock.create.assert_called_with(
|
||||||
volume_fakes.volume_size,
|
self.new_volume.size,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
volume_fakes.volume_name,
|
self.new_volume.display_name,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -503,6 +505,7 @@ class TestVolumeDelete(TestVolume):
|
|||||||
|
|
||||||
class TestVolumeList(TestVolume):
|
class TestVolumeList(TestVolume):
|
||||||
|
|
||||||
|
_volume = volume_fakes.FakeVolume.create_one_volume()
|
||||||
columns = (
|
columns = (
|
||||||
'ID',
|
'ID',
|
||||||
'Display Name',
|
'Display Name',
|
||||||
@ -510,26 +513,23 @@ class TestVolumeList(TestVolume):
|
|||||||
'Size',
|
'Size',
|
||||||
'Attached to',
|
'Attached to',
|
||||||
)
|
)
|
||||||
|
server = _volume.attachments[0]['server_id']
|
||||||
|
device = _volume.attachments[0]['device']
|
||||||
|
msg = 'Attached to %s on %s ' % (server, device)
|
||||||
datalist = (
|
datalist = (
|
||||||
(
|
(
|
||||||
volume_fakes.volume_id,
|
_volume.id,
|
||||||
volume_fakes.volume_name,
|
_volume.display_name,
|
||||||
volume_fakes.volume_status,
|
_volume.status,
|
||||||
volume_fakes.volume_size,
|
_volume.size,
|
||||||
'',
|
msg,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestVolumeList, self).setUp()
|
super(TestVolumeList, self).setUp()
|
||||||
|
|
||||||
self.volumes_mock.list.return_value = [
|
self.volumes_mock.list.return_value = [self._volume]
|
||||||
fakes.FakeResource(
|
|
||||||
None,
|
|
||||||
copy.deepcopy(volume_fakes.VOLUME),
|
|
||||||
loaded=True,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = volume.ListVolume(self.app, None)
|
self.cmd = volume.ListVolume(self.app, None)
|
||||||
@ -552,12 +552,12 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
def test_volume_list_name(self):
|
def test_volume_list_name(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--name', volume_fakes.volume_name,
|
'--name', self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('long', False),
|
('long', False),
|
||||||
('all_projects', False),
|
('all_projects', False),
|
||||||
('name', volume_fakes.volume_name),
|
('name', self._volume.display_name),
|
||||||
('status', None),
|
('status', None),
|
||||||
('limit', None),
|
('limit', None),
|
||||||
]
|
]
|
||||||
@ -569,13 +569,13 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
def test_volume_list_status(self):
|
def test_volume_list_status(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--status', volume_fakes.volume_status,
|
'--status', self._volume.status,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('long', False),
|
('long', False),
|
||||||
('all_projects', False),
|
('all_projects', False),
|
||||||
('name', None),
|
('name', None),
|
||||||
('status', volume_fakes.volume_status),
|
('status', self._volume.status),
|
||||||
('limit', None),
|
('limit', None),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -630,14 +630,14 @@ class TestVolumeList(TestVolume):
|
|||||||
self.assertEqual(collist, columns)
|
self.assertEqual(collist, columns)
|
||||||
|
|
||||||
datalist = ((
|
datalist = ((
|
||||||
volume_fakes.volume_id,
|
self._volume.id,
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
volume_fakes.volume_status,
|
self._volume.status,
|
||||||
volume_fakes.volume_size,
|
self._volume.size,
|
||||||
volume_fakes.volume_type,
|
self._volume.volume_type,
|
||||||
'',
|
self._volume.bootable,
|
||||||
'',
|
self.msg,
|
||||||
"Alpha='a', Beta='b', Gamma='g'",
|
utils.format_dict(self._volume.metadata),
|
||||||
), )
|
), )
|
||||||
self.assertEqual(datalist, tuple(data))
|
self.assertEqual(datalist, tuple(data))
|
||||||
|
|
||||||
@ -679,33 +679,27 @@ class TestVolumeList(TestVolume):
|
|||||||
|
|
||||||
class TestVolumeSet(TestVolume):
|
class TestVolumeSet(TestVolume):
|
||||||
|
|
||||||
|
_volume = volume_fakes.FakeVolume.create_one_volume()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestVolumeSet, self).setUp()
|
super(TestVolumeSet, self).setUp()
|
||||||
|
|
||||||
self.volumes_mock.get.return_value = fakes.FakeResource(
|
self.volumes_mock.get.return_value = self._volume
|
||||||
None,
|
|
||||||
copy.deepcopy(volume_fakes.VOLUME),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.volumes_mock.update.return_value = fakes.FakeResource(
|
self.volumes_mock.update.return_value = self._volume
|
||||||
None,
|
|
||||||
copy.deepcopy(volume_fakes.VOLUME),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = volume.SetVolume(self.app, None)
|
self.cmd = volume.SetVolume(self.app, None)
|
||||||
|
|
||||||
def test_volume_set_no_options(self):
|
def test_volume_set_no_options(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', None),
|
('name', None),
|
||||||
('description', None),
|
('description', None),
|
||||||
('size', None),
|
('size', None),
|
||||||
('property', None),
|
('property', None),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -715,14 +709,14 @@ class TestVolumeSet(TestVolume):
|
|||||||
def test_volume_set_name(self):
|
def test_volume_set_name(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--name', 'qwerty',
|
'--name', 'qwerty',
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', 'qwerty'),
|
('name', 'qwerty'),
|
||||||
('description', None),
|
('description', None),
|
||||||
('size', None),
|
('size', None),
|
||||||
('property', None),
|
('property', None),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -733,7 +727,7 @@ class TestVolumeSet(TestVolume):
|
|||||||
'display_name': 'qwerty',
|
'display_name': 'qwerty',
|
||||||
}
|
}
|
||||||
self.volumes_mock.update.assert_called_with(
|
self.volumes_mock.update.assert_called_with(
|
||||||
volume_fakes.volume_id,
|
self._volume.id,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
@ -741,14 +735,14 @@ class TestVolumeSet(TestVolume):
|
|||||||
def test_volume_set_description(self):
|
def test_volume_set_description(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--description', 'new desc',
|
'--description', 'new desc',
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', None),
|
('name', None),
|
||||||
('description', 'new desc'),
|
('description', 'new desc'),
|
||||||
('size', None),
|
('size', None),
|
||||||
('property', None),
|
('property', None),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -759,7 +753,7 @@ class TestVolumeSet(TestVolume):
|
|||||||
'display_description': 'new desc',
|
'display_description': 'new desc',
|
||||||
}
|
}
|
||||||
self.volumes_mock.update.assert_called_with(
|
self.volumes_mock.update.assert_called_with(
|
||||||
volume_fakes.volume_id,
|
self._volume.id,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
@ -767,14 +761,14 @@ class TestVolumeSet(TestVolume):
|
|||||||
def test_volume_set_size(self):
|
def test_volume_set_size(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', '130',
|
'--size', '130',
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', None),
|
('name', None),
|
||||||
('description', None),
|
('description', None),
|
||||||
('size', 130),
|
('size', 130),
|
||||||
('property', None),
|
('property', None),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -783,23 +777,24 @@ class TestVolumeSet(TestVolume):
|
|||||||
# Set expected values
|
# Set expected values
|
||||||
size = 130
|
size = 130
|
||||||
self.volumes_mock.extend.assert_called_with(
|
self.volumes_mock.extend.assert_called_with(
|
||||||
volume_fakes.volume_id,
|
self._volume.id,
|
||||||
size
|
size
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
@mock.patch.object(volume.LOG, 'error')
|
@mock.patch.object(volume.LOG, 'error')
|
||||||
def test_volume_set_size_smaller(self, mock_log_error):
|
def test_volume_set_size_smaller(self, mock_log_error):
|
||||||
|
self._volume.status = 'available'
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', '100',
|
'--size', '1',
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', None),
|
('name', None),
|
||||||
('description', None),
|
('description', None),
|
||||||
('size', 100),
|
('size', 1),
|
||||||
('property', None),
|
('property', None),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -807,22 +802,22 @@ class TestVolumeSet(TestVolume):
|
|||||||
|
|
||||||
mock_log_error.assert_called_with("New size must be greater "
|
mock_log_error.assert_called_with("New size must be greater "
|
||||||
"than %s GB",
|
"than %s GB",
|
||||||
volume_fakes.volume_size)
|
self._volume.size)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
@mock.patch.object(volume.LOG, 'error')
|
@mock.patch.object(volume.LOG, 'error')
|
||||||
def test_volume_set_size_not_available(self, mock_log_error):
|
def test_volume_set_size_not_available(self, mock_log_error):
|
||||||
self.volumes_mock.get.return_value.status = 'error'
|
self._volume.status = 'error'
|
||||||
arglist = [
|
arglist = [
|
||||||
'--size', '130',
|
'--size', '130',
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', None),
|
('name', None),
|
||||||
('description', None),
|
('description', None),
|
||||||
('size', 130),
|
('size', 130),
|
||||||
('property', None),
|
('property', None),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -836,14 +831,14 @@ class TestVolumeSet(TestVolume):
|
|||||||
def test_volume_set_property(self):
|
def test_volume_set_property(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--property', 'myprop=myvalue',
|
'--property', 'myprop=myvalue',
|
||||||
volume_fakes.volume_name,
|
self._volume.display_name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', None),
|
('name', None),
|
||||||
('description', None),
|
('description', None),
|
||||||
('size', None),
|
('size', None),
|
||||||
('property', {'myprop': 'myvalue'}),
|
('property', {'myprop': 'myvalue'}),
|
||||||
('volume', volume_fakes.volume_name),
|
('volume', self._volume.display_name),
|
||||||
('bootable', False),
|
('bootable', False),
|
||||||
('non_bootable', False)
|
('non_bootable', False)
|
||||||
]
|
]
|
||||||
@ -856,26 +851,26 @@ class TestVolumeSet(TestVolume):
|
|||||||
'myprop': 'myvalue'
|
'myprop': 'myvalue'
|
||||||
}
|
}
|
||||||
self.volumes_mock.set_metadata.assert_called_with(
|
self.volumes_mock.set_metadata.assert_called_with(
|
||||||
volume_fakes.volume_id,
|
self._volume.id,
|
||||||
metadata
|
metadata
|
||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_volume_set_bootable(self):
|
def test_volume_set_bootable(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
['--bootable', volume_fakes.volume_id],
|
['--bootable', self._volume.id],
|
||||||
['--non-bootable', volume_fakes.volume_id]
|
['--non-bootable', self._volume.id]
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
[
|
[
|
||||||
('bootable', True),
|
('bootable', True),
|
||||||
('non_bootable', False),
|
('non_bootable', False),
|
||||||
('volume', volume_fakes.volume_id)
|
('volume', self._volume.id)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
('bootable', False),
|
('bootable', False),
|
||||||
('non_bootable', True),
|
('non_bootable', True),
|
||||||
('volume', volume_fakes.volume_id)
|
('volume', self._volume.id)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
for index in range(len(arglist)):
|
for index in range(len(arglist)):
|
||||||
@ -884,4 +879,4 @@ class TestVolumeSet(TestVolume):
|
|||||||
|
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.volumes_mock.set_bootable.assert_called_with(
|
self.volumes_mock.set_bootable.assert_called_with(
|
||||||
volume_fakes.volume_id, verifylist[index][0][1])
|
self._volume.id, verifylist[index][0][1])
|
||||||
|
Loading…
Reference in New Issue
Block a user