'Test snapshot can be created and deleted.'

@mock.patch('cinder.tests.unit.fake_notifier.FakeNotifier._notify')
def test_create_delete_snapshot(self, mock_notify):

    volume = tests_utils.create_volume(self.context, availability_zone=CONF.storage_availability_zone, **self.volume_params)
    mock_notify.assert_not_called()
    self.volume.create_volume(self.context, volume)
    self.assert_notify_called(mock_notify, (['INFO', 'volume.create.start'], ['INFO', 'volume.create.end']))
    snapshot = create_snapshot(volume['id'], size=volume['size'])
    snapshot_id = snapshot.id
    self.volume.create_snapshot(self.context, snapshot)
    self.assertEqual(snapshot_id, objects.Snapshot.get_by_id(self.context, snapshot_id).id)
    self.assert_notify_called(mock_notify, (['INFO', 'volume.create.start'], ['INFO', 'volume.create.end'], ['INFO', 'snapshot.create.start'], ['INFO', 'snapshot.create.end']))
    self.volume.delete_snapshot(self.context, snapshot)
    self.assert_notify_called(mock_notify, (['INFO', 'volume.create.start'], ['INFO', 'volume.create.end'], ['INFO', 'snapshot.create.start'], ['INFO', 'snapshot.create.end'], ['INFO', 'snapshot.delete.start'], ['INFO', 'snapshot.delete.end']))
    snap = objects.Snapshot.get_by_id(context.get_admin_context(read_deleted='yes'), snapshot_id)
    self.assertEqual(fields.SnapshotStatus.DELETED, snap.status)
    self.assertRaises(exception.NotFound, db.snapshot_get, self.context, snapshot_id)
    self.volume.delete_volume(self.context, volume)
