'Test volume can be created and deleted.'

@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
@mock.patch('cinder.quota.QUOTAS.rollback', new=mock.Mock())
@mock.patch('cinder.quota.QUOTAS.commit', new=mock.Mock())
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=['RESERVATION'])
def test_create_delete_volume(self, _mock_reserve, mock_notify):

    volume = tests_utils.create_volume(self.context, availability_zone=CONF.storage_availability_zone, **self.volume_params)
    volume_id = volume['id']
    mock_notify.assert_not_called()
    self.assertIsNone(volume['encryption_key_id'])
    self.volume.create_volume(self.context, volume)
    self.assert_notify_called(mock_notify, (['INFO', 'volume.create.start'], ['INFO', 'volume.create.end']))
    self.volume.delete_volume(self.context, volume)
    vol = db.volume_get(context.get_admin_context(read_deleted='yes'), volume_id)
    self.assertEqual(vol['status'], 'deleted')
    self.assert_notify_called(mock_notify, (['INFO', 'volume.create.start'], ['INFO', 'volume.create.end'], ['INFO', 'volume.delete.start'], ['INFO', 'volume.delete.end']))
    self.assertRaises(exception.NotFound, db.volume_get, self.context, volume_id)
