'Test init_host_with_service in case of snapshot.
While the status of snapshot is \'creating\', volume process
down. After process restarting this \'creating\' status is
changed to \'error\'.'

def test_create_snapshot_fails_with_creating_status(self):

    volume = tests_utils.create_volume(self.context, **self.volume_params)
    snapshot = tests_utils.create_snapshot(self.context, volume.id, status=fields.SnapshotStatus.CREATING)
    db.worker_create(self.context, resource_type='Snapshot', resource_id=snapshot.id, status=snapshot.status, service_id=self.service_id)
    self.volume.init_host(service_id=service.Service.service_id)
    snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot.id)
    self.assertEqual(fields.SnapshotStatus.ERROR, snapshot_obj.status)
    self.assertEqual(service.Service.service_id, self.volume.service_id)
    self._assert_workers_are_removed()
    self.volume.delete_snapshot(self.context, snapshot_obj)
    self.volume.delete_volume(self.context, volume)
