Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store service task response in task data #227

Merged
merged 4 commits into from Sep 19, 2022
Merged

Conversation

jbirddog
Copy link
Contributor

Supports storing the response of a service task in task data. An optional resultVariable attribute is supported for naming the task data key. If one is not specified a variable name will be constructed based off the spec name. Tested via the front end, which after running a sample diagram to hit bamboohr:

Event_0fy5yvl: COMPLETED

{
  "current_user": {
    "id": "1",
    "username": "56457e8f-47c6-4f9f-a72b-473dea5edfeb"
  },
  "spiff__service_task_one_result": {
    "amount": "65000.00",
    "currency": "USD",
    "id": "4",
    "payRate": "65000.00 USD"
  }
}

if self.result_variable is not None and len(self.result_variable) > 0:
return self.result_variable

return f'spiff__{task.task_spec.name}_result'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to normalize this in any way? can task_spec.name include spaces or hyphens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, looks like dashes can be in the name - I'll convert them to underscores.

@sonarcloud
Copy link

sonarcloud bot commented Sep 19, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Collaborator

@danfunk danfunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@@ -11,21 +12,35 @@
from SpiffWorkflow.bpmn.exceptions import WorkflowTaskExecException
from .BaseTestCase import BaseTestCase

# TODO must be a better way to do this
assertEqual = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand why this was here, checked out the code, ran it, and it doesn't need to be here. What is it for?!?!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asking about the "AssertEqual = None" - but commented on the wrong line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test case setUp, the global is set to self.assertEqual so that the mock connector can assert its name and params. Didn't realize you could omit this line and the global assertEqual on line 52 would create the variable.

@danfunk danfunk merged commit 3cb0345 into main Sep 19, 2022
@danfunk danfunk deleted the service_task_response branch September 21, 2022 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants