def test_update_workflow_pipeline_not_found(app, organization_workflow, organization_pipeline, organization_workflow_pipeline): wf_uuid = organization_workflow.workflow_uuid wf_pipeline_uuid = organization_workflow_pipeline.workflow_pipeline_uuid responses.add( responses.PUT, f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows/{wf_uuid}/pipelines/{wf_pipeline_uuid}", json={"not": "found"}, status=404, ) with pytest.raises(ValueError): update_workflow_pipeline( organization_workflow.organization_uuid, organization_workflow.uuid, organization_workflow_pipeline.uuid, { "source_workflow_pipelines": [ organization_workflow_pipeline.uuid, ], "pipeline_uuid": organization_pipeline.uuid, "destination_workflow_pipelines": [ organization_workflow_pipeline.uuid, ], }, )
def test_update_workflow_pipeline_remove_bad_ids(app, pipeline, workflow_pipeline): with pytest.raises(ValueError): workflow_pipeline = services.update_workflow_pipeline( workflow_pipeline.workflow.uuid, workflow_pipeline.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline, ["0" * 32]), ) with pytest.raises(ValueError): workflow_pipeline = services.update_workflow_pipeline( workflow_pipeline.workflow.uuid, workflow_pipeline.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline, [], ["0" * 32]), ) with pytest.raises(ValueError): workflow_pipeline = services.update_workflow_pipeline( workflow_pipeline.workflow.uuid, workflow_pipeline.uuid, { "pipeline_uuid": "0" * 32, "source_workflow_pipelines": [], "destination_workflow_pipelines": [], }, )
def test_update_workflow_pipeline_bad_json(app, organization_workflow, organization_pipeline, organization_workflow_pipeline): wf_uuid = organization_workflow.workflow_uuid wf_pipeline_uuid = organization_workflow_pipeline.workflow_pipeline_uuid responses.add( responses.PUT, f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows/{wf_uuid}/pipelines/{wf_pipeline_uuid}", body="notjson", status=503, ) with pytest.raises(HTTPError): update_workflow_pipeline( organization_workflow.organization_uuid, organization_workflow.uuid, organization_workflow_pipeline.uuid, { "source_workflow_pipelines": [ organization_workflow_pipeline.uuid, ], "pipeline_uuid": organization_pipeline.uuid, "destination_workflow_pipelines": [ organization_workflow_pipeline.uuid, ], }, )
def test_update_workflow_pipeline_invalid_org_workflow_pipeline( app, organization_workflow, organization_pipeline, organization_workflow_pipeline): with pytest.raises(ValueError): update_workflow_pipeline( organization_workflow.organization_uuid, organization_workflow.uuid, "1234", { "pipeline_uuid": organization_pipeline.uuid, "destination_workflow_pipelines": [], "source_workflow_pipelines": [], }, )
def test_update_workflow_pipeline_add_dest(app, pipeline, workflow_pipeline): pipeline_with_dest = services.create_workflow_pipeline( workflow_pipeline.workflow.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline, [], [workflow_pipeline.uuid]), ) new_dest = services.create_workflow_pipeline( workflow_pipeline.workflow.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline), ) updated_pipeline = services.update_workflow_pipeline( pipeline_with_dest.workflow.uuid, pipeline_with_dest.uuid, _create_workflow_pipeline_json( workflow_pipeline.pipeline, [], [workflow_pipeline.uuid, new_dest.uuid, new_dest.uuid], ), ) assert updated_pipeline.pipeline == pipeline assert [ s.to_workflow_pipeline for s in updated_pipeline.dest_workflow_pipelines ] == [workflow_pipeline, new_dest] assert [ s.from_workflow_pipeline for s in updated_pipeline.dest_workflow_pipelines ] == [updated_pipeline, updated_pipeline] assert updated_pipeline.source_workflow_pipelines == [] # removing a dest also happens! updated_pipeline = services.update_workflow_pipeline( pipeline_with_dest.workflow.uuid, pipeline_with_dest.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline, [], [workflow_pipeline.uuid]), ) assert [ s.to_workflow_pipeline for s in updated_pipeline.dest_workflow_pipelines ] == [workflow_pipeline] updated_pipeline = services.update_workflow_pipeline( pipeline_with_dest.workflow.uuid, pipeline_with_dest.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline), ) assert updated_pipeline.source_workflow_pipelines == [] assert updated_pipeline.dest_workflow_pipelines == []
def workflow_pipeline_update( organization_uuid, organization_workflow_uuid, organization_workflow_pipeline_uuid ): """Update Organization Workflow Pipeline. --- tags: - workflows parameters: - in: header name: Workflow-API-Key description: Requires key type REACT_CLIENT schema: type: string responses: "200": description: "Update Organization Workflow Pipeline." content: application/json: schema: type: object properties: pipeline_uuid: type: string source_workflow_pipelines: type: array items: type: string destination_workflow_pipelines: type: array items: type: string uuid: type: string created_at: type: string updated_at: type: string "400": description: "Bad request" "503": description: "Http error" """ try: return jsonify( update_workflow_pipeline( organization_uuid, organization_workflow_uuid, organization_workflow_pipeline_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 except ValidationError as validation_err: return {"message": "Validation error", "errors": validation_err.messages}, 400
def test_update_workflow_pipeline_no_change(app, pipeline, workflow_pipeline): workflow_pipeline = services.update_workflow_pipeline( workflow_pipeline.workflow.uuid, workflow_pipeline.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline), ) assert workflow_pipeline.pipeline == pipeline assert workflow_pipeline.source_workflow_pipelines == [] assert workflow_pipeline.dest_workflow_pipelines == []
def test_update_workflow_pipeline_update_pipeline(app, pipeline, workflow_pipeline): new_pipeline = create_pipeline(PIPELINE_JSON) db.session.commit() new_json = _create_workflow_pipeline_json(workflow_pipeline.pipeline) new_json["pipeline_uuid"] = new_pipeline.uuid workflow_pipeline = services.update_workflow_pipeline( workflow_pipeline.workflow.uuid, workflow_pipeline.uuid, new_json) assert workflow_pipeline.pipeline == new_pipeline assert workflow_pipeline.source_workflow_pipelines == [] assert workflow_pipeline.dest_workflow_pipelines == []
def test_update_workflow_pipeline(app, organization_workflow, organization_pipeline, organization_workflow_pipeline): wf_uuid = organization_workflow.workflow_uuid wf_pipeline_uuid = organization_workflow_pipeline.workflow_pipeline_uuid mock_response = copy.deepcopy(WORKFLOW_PIPELINE_RESPONSE_JSON) mock_response["source_workflow_pipelines"].append( organization_workflow_pipeline.uuid) mock_response["destination_workflow_pipelines"].append( organization_workflow_pipeline.uuid) responses.add( responses.PUT, f"{app.config[WORKFLOW_HOSTNAME]}/v1/workflows/{wf_uuid}/pipelines/{wf_pipeline_uuid}", json=mock_response, ) update_wf_pipeline = update_workflow_pipeline( organization_workflow.organization_uuid, organization_workflow.uuid, organization_workflow_pipeline.uuid, { "source_workflow_pipelines": [ organization_workflow_pipeline.uuid, organization_workflow_pipeline.uuid, ], "pipeline_uuid": organization_pipeline.uuid, "destination_workflow_pipelines": [ organization_workflow_pipeline.uuid, organization_workflow_pipeline.uuid, ], }, ) assert update_wf_pipeline.get( "uuid") == organization_workflow_pipeline.uuid assert update_wf_pipeline.get( "pipeline_uuid") == organization_pipeline.uuid for key in ["source_workflow_pipelines", "destination_workflow_pipelines"]: assert all(ow_p == organization_workflow_pipeline.uuid for ow_p in update_wf_pipeline[key])
def test_update_workflow_pipeline_bad_id(app, workflow_pipeline): with pytest.raises(ValueError): services.update_workflow_pipeline( "0" * 32, "0" * 32, _create_workflow_pipeline_json(workflow_pipeline.pipeline), ) with pytest.raises(ValueError): services.update_workflow_pipeline( "0" * 32, workflow_pipeline.uuid, _create_workflow_pipeline_json(workflow_pipeline.pipeline), ) with pytest.raises(ValueError): services.update_workflow_pipeline( workflow_pipeline.workflow.uuid, "0" * 32, _create_workflow_pipeline_json(workflow_pipeline.pipeline), )