def test_create_workflow_bad_response(app): responses.add( responses.POST, f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows", json=WORKFLOW_JSON, status=500, ) with pytest.raises(ValueError): create_workflow(ORGANIZATION_UUID, WORKFLOW_JSON)
def test_create_workflow_bad_params(app): workflow = services.create_workflow({ "name": "a workflow", "description": "desc" }) assert workflow.uuid is not None assert workflow.name == "a workflow" assert workflow.description == "desc"
def create(organization_uuid): """Create a Organization Workflow. --- tags: - workflows parameters: - in: header name: Workflow-API-Key description: Requires key type REACT_CLIENT schema: type: string requestBody: description: "Workflow name and description." required: true content: application/json: schema: type: object properties: name: type: string description: type: string responses: "200": description: "Updated OrganizationWorkflow" content: application/json: schema: type: object properties: uuid: type: string name: type: string description: type: string docker_image_url: type: string repository_ssh_url: type: string repository_branch: type: string created_at: type: string updated_at: type: string "400": description: "Bad request" "503": description: "Http error" """ try: return jsonify(create_workflow(organization_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
def test_create_workflow_bad_params(app): with pytest.raises(ValidationError): services.create_workflow(None) with pytest.raises(ValidationError): services.create_workflow({}) with pytest.raises(ValidationError): services.create_workflow({"name": "", "description": ""})
def test_create_workflow(app): json_response = dict(WORKFLOW_JSON) json_response.update({ "created_at": "2020-10-08T14:22:26.276242", "updated_at": "2020-10-08T14:22:26.276278", "uuid": "83ac3b4e9433431fbd6d21e7a56b6f0a", }) responses.add( responses.POST, f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows", json=json_response, ) created_workflow = create_workflow(ORGANIZATION_UUID, WORKFLOW_JSON) workflow = OrganizationWorkflow.query.order_by( OrganizationWorkflow.id.desc()).first() json_response["uuid"] = workflow.uuid assert created_workflow == json_response
def test_create_workflow_bad_json(app): responses.add(responses.POST, f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows", body="notjson") with pytest.raises(HTTPError): create_workflow(ORGANIZATION_UUID, WORKFLOW_JSON)