FUP: add missing test for PUT volume attachments API
This patch aims to address the comments in https://review.opendev.org/#/c/693828/25/nova/tests/unit/api/openstack/compute/test_volumes.py@1342 Blueprint: destroy-instance-with-datavolume Change-Id: Ie9ae31cf3ab7ca108f132e4e0aff56368c40e6f7
This commit is contained in:
parent
22ce38aae4
commit
efc945152d
|
@ -96,8 +96,9 @@ del update_volume_attachment['properties']['volumeAttachment'][
|
|||
'properties']['device']
|
||||
|
||||
# NOTE(brinzhang): Allow attachment_id, serverId, device, tag, and
|
||||
# delete_on_termination to be specified for RESTfulness, even though
|
||||
# we will not allow updating all of them.
|
||||
# delete_on_termination (i.e., follow the content of the GET response)
|
||||
# to be specified for RESTfulness, even though we will not allow updating
|
||||
# all of them.
|
||||
update_volume_attachment_v285 = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
|
|
|
@ -1336,6 +1336,22 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
|
|||
self.req, FAKE_UUID,
|
||||
FAKE_UUID_A, body=body)
|
||||
|
||||
@mock.patch.object(objects.BlockDeviceMapping,
|
||||
'get_by_volume_and_instance')
|
||||
def test_update_volume_with_changed_attachment_id_old_microversion(
|
||||
self, mock_get_vol_and_inst):
|
||||
body = {'volumeAttachment': {
|
||||
'volumeId': FAKE_UUID_A,
|
||||
'id': uuids.attachment_id,
|
||||
}}
|
||||
req = self._get_req(body, microversion='2.84')
|
||||
ex = self.assertRaises(exception.ValidationError,
|
||||
self.attachments.update,
|
||||
req, FAKE_UUID,
|
||||
FAKE_UUID_A, body=body)
|
||||
self.assertIn('Additional properties are not allowed',
|
||||
six.text_type(ex))
|
||||
|
||||
@mock.patch.object(objects.BlockDeviceMapping,
|
||||
'get_by_volume_and_instance')
|
||||
def test_update_volume_with_changed_serverId(self,
|
||||
|
@ -1363,6 +1379,22 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
|
|||
self.req, FAKE_UUID,
|
||||
FAKE_UUID_A, body=body)
|
||||
|
||||
@mock.patch.object(objects.BlockDeviceMapping,
|
||||
'get_by_volume_and_instance')
|
||||
def test_update_volume_with_changed_serverId_old_microversion(
|
||||
self, mock_get_vol_and_inst):
|
||||
body = {'volumeAttachment': {
|
||||
'volumeId': FAKE_UUID_A,
|
||||
'serverId': uuids.server_id,
|
||||
}}
|
||||
req = self._get_req(body, microversion='2.84')
|
||||
ex = self.assertRaises(exception.ValidationError,
|
||||
self.attachments.update,
|
||||
req, FAKE_UUID,
|
||||
FAKE_UUID_A, body=body)
|
||||
self.assertIn('Additional properties are not allowed',
|
||||
six.text_type(ex))
|
||||
|
||||
@mock.patch.object(objects.BlockDeviceMapping,
|
||||
'get_by_volume_and_instance')
|
||||
def test_update_volume_with_changed_device(self, mock_get_vol_and_inst):
|
||||
|
|
Loading…
Reference in New Issue