Пример #1
0
def test_update_workflow_invalid_org_missing_params(app,
                                                    organization_workflow):
    with pytest.raises(ValueError):
        update_workflow("1234", organization_workflow.uuid, {})

    with pytest.raises(ValueError):
        update_workflow(ORGANIZATION_UUID, organization_workflow.uuid,
                        {"missing": "params"})
Пример #2
0
def test_update_workflow_bad_workflow_responses(app, organization_workflow):
    updates = {"name": "123", "description": "456"}
    json_response = dict(WORKFLOW_JSON)
    json_response.update(updates)

    responses.add(
        responses.PUT,
        f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows/{WORKFLOW_UUID}",
        status=500,
    )

    with pytest.raises(HTTPError):
        update_workflow(ORGANIZATION_UUID, organization_workflow.uuid, updates)
Пример #3
0
def test_update_workflow_not_found(app, organization_workflow):
    updates = {"name": "123", "description": "456"}
    json_response = dict(WORKFLOW_JSON)
    json_response.update(updates)

    responses.add(
        responses.PUT,
        f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows/{WORKFLOW_UUID}",
        json={"error": "not found"},
        status=404,
    )

    with pytest.raises(ValueError):
        update_workflow(ORGANIZATION_UUID, organization_workflow.uuid, updates)
Пример #4
0
def test_update_workflow_bad_params(app, workflow):
    workflow = services.update_workflow(workflow.uuid, {
        "name": "updated workflow",
        "description": "update desc"
    })
    assert workflow.uuid is not None
    assert workflow.name == "updated workflow"
    assert workflow.description == "update desc"
Пример #5
0
def test_update_workflow(app, organization_workflow):
    updates = {"name": "123", "description": "456"}
    json_response = dict(WORKFLOW_JSON)
    json_response.update(updates)

    responses.add(
        responses.PUT,
        f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows/{WORKFLOW_UUID}",
        json=json_response,
    )
    updated_workflow = update_workflow(ORGANIZATION_UUID,
                                       organization_workflow.uuid, updates)

    json_response["uuid"] = organization_workflow.uuid
    assert updated_workflow == json_response
Пример #6
0
def test_update_workflow_bad_params(app, workflow):
    with pytest.raises(ValueError):
        services.update_workflow("no-id", {"name": "", "description": ""})
    with pytest.raises(ValidationError):
        services.update_workflow(workflow.uuid, {})
    with pytest.raises(ValidationError):
        services.update_workflow(workflow.uuid, {
            "name": "",
            "description": ""
        })
Пример #7
0
def workflow_update(organization_uuid, organization_workflow_uuid):
    """Updates Organization Workflow.
    ---
    tags:
      - workflows
    parameters:
      - in: header
        name: Workflow-API-Key
        description: Requires key type REACT_CLIENT
        schema:
          type: string
    responses:
      "200":
        description: "Updated OrganizationWorkflow"
        content:
          application/json:
            schema:
              type: object
              properties:
                uuid:
                  type: string
                name:
                  type: string
                description:
                  type: string
                created_at:
                  type: string
                updated_at:
                  type: string
      "400":
        description: "Bad request"
      "503":
        description: "Http error"
    """
    try:
        return jsonify(
            update_workflow(organization_uuid, organization_workflow_uuid, request.json)
        )
    except HTTPError as http_error:
        return {"message": http_error.args[0]}, 503
    except ValueError as value_error:
        return jsonify(value_error.args[0]), 400