def test_execute_one_task_error(app, create_builder):
    (workflow, builder) = create_builder('example', 'ERROR', {})
    assert (workflow['status'] == 'pending')
    assert (len(builder.canvas) == 3)
    assert (builder.canvas[0].task == 'director.tasks.workflows.start')
    assert (builder.canvas[(- 1)].task == 'director.tasks.workflows.end')
    assert (builder.canvas[1].task == 'TASK_ERROR')
    with app.app_context():
        tasks = Task.query.order_by(Task.created_at.asc()).all()
    assert (len(tasks) == 1)
    assert (tasks[0].key == 'TASK_ERROR')
    assert (tasks[0].status.value == 'pending')
    result = builder.run()
    with pytest.raises(ZeroDivisionError):
        assert result.get()
    time.sleep(0.5)
    with app.app_context():
        task = Task.query.filter_by(id=tasks[0].id).first()
        workflow = Workflow.query.filter_by(id=task.workflow_id).first()
    assert (workflow.status.value == 'error')
    assert (task.status.value == 'error')
def test_execute_one_task_error(app, create_builder):
    (workflow, builder) = create_builder('example', 'ERROR', {})
    assert (workflow['status'] == 'pending')
    assert (len(builder.canvas) == 3)
    assert (builder.canvas[0].task == 'director.tasks.workflows.start')
    assert (builder.canvas[(- 1)].task == 'director.tasks.workflows.end')
    assert (builder.canvas[1].task == 'TASK_ERROR')
    with app.app_context():
        tasks = Task.query.order_by(Task.created_at.asc()).all()
    assert (len(tasks) == 1)
    assert (tasks[0].key == 'TASK_ERROR')
    assert (tasks[0].status.value == 'pending')
    result = builder.run()
    with pytest.raises(ZeroDivisionError):
        assert result.get()
    time.sleep(0.5)
    with app.app_context():
        task = Task.query.filter_by(id=tasks[0].id).first()
        workflow = Workflow.query.filter_by(id=task.workflow_id).first()
    assert (workflow.status.value == 'error')
    assert (task.status.value == 'error')