Merge "FUP: add missing test for PUT volume attachments API"

This commit is contained in:
Zuul 2020-04-10 05:21:16 +00:00 committed by Gerrit Code Review
commit aaa3803807
2 changed files with 35 additions and 2 deletions

View File

@ -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': {

View File

@ -1384,6 +1384,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,
@ -1411,6 +1427,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):