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

@mock.patch('cinder.image.image_utils.cleanup_temporary_file')
def test_create_volume_fails_with_creating_and_downloading_status(self, mock_cleanup_tmp_file):

    for status in ('creating', 'downloading'):
        volume = tests_utils.create_volume(self.context, status=status, size=0, host=CONF.host)
        db.worker_create(self.context, resource_type='Volume', resource_id=volume.id, status=volume.status, service_id=self.service_id)
        self.volume.init_host(service_id=service.Service.service_id)
        volume.refresh()
        self.assertEqual('error', volume['status'])
        self.volume.delete_volume(self.context, volume)
        self.assertTrue(mock_cleanup_tmp_file.called)
        self._assert_workers_are_removed()
