def test_volume_creation_from_backup(self, max_ver, create, get_backup, volume_type_get): create.side_effect = v2_fakes.fake_volume_api_create get_backup.side_effect = v2_fakes.fake_backup_get volume_type_get.side_effect = v2_fakes.fake_volume_type_get backup_id = fake.BACKUP_ID req = fakes.HTTPRequest.blank('/v3/volumes') req.api_version_request = mv.get_api_version(max_ver) if max_ver == mv.VOLUME_CREATE_FROM_BACKUP: vol = self._vol_in_request_body(backup_id=backup_id) else: vol = self._vol_in_request_body() body = {"volume": vol} res_dict = self.controller.create(req, body=body) ex = self._expected_vol_from_controller( req_version=req.api_version_request) self.assertEqual(ex, res_dict) context = req.environ['cinder.context'] kwargs = self._expected_volume_api_create_kwargs( req_version=req.api_version_request) if max_ver >= mv.VOLUME_CREATE_FROM_BACKUP: get_backup.assert_called_once_with(self.controller.backup_api, context, backup_id) kwargs.update({'backup': v2_fakes.fake_backup_get(None, context, backup_id)}) create.assert_called_once_with(self.controller.volume_api, context, vol['size'], v2_fakes.DEFAULT_VOL_NAME, v2_fakes.DEFAULT_VOL_DESCRIPTION, **kwargs)