Skip to content

Commit b1f362b

Browse files
Merge pull request #12 from InformaticsMatters/prototype-work-alan
Consistent error parameter naming
2 parents 9298e91 + 1d2dad6 commit b1f362b

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

tests/test_test_api_adapter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_set_running_workflow_done_when_success():
114114
response, _ = utaa.get_running_workflow(running_workflow_id=rwfid)
115115
assert response["done"]
116116
assert response["success"]
117-
assert response["error"] is None
117+
assert response["error_num"] is None
118118
assert response["error_msg"] is None
119119

120120

@@ -132,14 +132,14 @@ def test_set_running_workflow_done_when_failed():
132132

133133
# Act
134134
utaa.set_running_workflow_done(
135-
running_workflow_id=rwfid, success=False, error=1, error_msg="Bang!"
135+
running_workflow_id=rwfid, success=False, error_num=1, error_msg="Bang!"
136136
)
137137

138138
# Assert
139139
response, _ = utaa.get_running_workflow(running_workflow_id=rwfid)
140140
assert response["done"]
141141
assert not response["success"]
142-
assert response["error"] == 1
142+
assert response["error_num"] == 1
143143
assert response["error_msg"] == "Bang!"
144144

145145

@@ -210,7 +210,7 @@ def test_set_running_workflow_step_done_when_success():
210210
response, _ = utaa.get_running_workflow_step(running_workflow_step_id=rwfsid)
211211
assert response["done"]
212212
assert response["success"]
213-
assert response["error"] is None
213+
assert response["error_num"] is None
214214
assert response["error_msg"] is None
215215
assert response["variables"] == {}
216216

@@ -232,14 +232,14 @@ def test_set_running_workflow_step_done_when_failed():
232232

233233
# Act
234234
utaa.set_running_workflow_step_done(
235-
running_workflow_step_id=rwfsid, success=False, error=1, error_msg="Bang!"
235+
running_workflow_step_id=rwfsid, success=False, error_num=1, error_msg="Bang!"
236236
)
237237

238238
# Assert
239239
response, _ = utaa.get_running_workflow_step(running_workflow_step_id=rwfsid)
240240
assert response["done"]
241241
assert not response["success"]
242-
assert response["error"] == 1
242+
assert response["error_num"] == 1
243243
assert response["error_msg"] == "Bang!"
244244

245245

tests/wapi_adapter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def set_running_workflow_done(
105105
*,
106106
running_workflow_id: str,
107107
success: bool,
108-
error: int | None = None,
108+
error_num: int | None = None,
109109
error_msg: str | None = None,
110110
) -> None:
111111
UnitTestWorkflowAPIAdapter.lock.acquire()
@@ -115,7 +115,7 @@ def set_running_workflow_done(
115115
assert running_workflow_id in running_workflow
116116
running_workflow[running_workflow_id]["done"] = True
117117
running_workflow[running_workflow_id]["success"] = success
118-
running_workflow[running_workflow_id]["error"] = error
118+
running_workflow[running_workflow_id]["error_num"] = error_num
119119
running_workflow[running_workflow_id]["error_msg"] = error_msg
120120

121121
with open(_RUNNING_WORKFLOW_PICKLE_FILE, "wb") as pickle_file:
@@ -184,7 +184,7 @@ def set_running_workflow_step_done(
184184
*,
185185
running_workflow_step_id: str,
186186
success: bool,
187-
error: int | None = None,
187+
error_num: int | None = None,
188188
error_msg: str | None = None,
189189
) -> None:
190190
UnitTestWorkflowAPIAdapter.lock.acquire()
@@ -194,7 +194,7 @@ def set_running_workflow_step_done(
194194
assert running_workflow_step_id in running_workflow_step
195195
running_workflow_step[running_workflow_step_id]["done"] = True
196196
running_workflow_step[running_workflow_step_id]["success"] = success
197-
running_workflow_step[running_workflow_step_id]["error"] = error
197+
running_workflow_step[running_workflow_step_id]["error_num"] = error_num
198198
running_workflow_step[running_workflow_step_id]["error_msg"] = error_msg
199199

200200
with open(_RUNNING_WORKFLOW_STEP_PICKLE_FILE, "wb") as pickle_file:

workflow/workflow_abc.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def get_running_workflow(
134134
# "running_user_api_token": "123456789",
135135
# "done": False,
136136
# "success": false,
137-
# "error": None,
138-
# "error_msg": None,
137+
# "error_num": 0,
138+
# "error_msg": "",
139139
# "workflow": {
140140
# "id": "workflow-000",
141141
# },
@@ -155,7 +155,7 @@ def set_running_workflow_done(
155155
*,
156156
running_workflow_id: str,
157157
success: bool,
158-
error: int | None = None,
158+
error_num: int | None = None,
159159
error_msg: str | None = None,
160160
) -> None:
161161
"""Set the success value for a RunningWorkflow Record.
@@ -184,8 +184,8 @@ def get_running_workflow_step(
184184
# "name:": "step-1234",
185185
# "done": False,
186186
# "success": false,
187-
# "error": None,
188-
# "error_msg": None,
187+
# "error_num": 0,
188+
# "error_msg": "",
189189
# "variables": {
190190
# "x": 1,
191191
# "y": 2,
@@ -213,7 +213,7 @@ def set_running_workflow_step_done(
213213
*,
214214
running_workflow_step_id: str,
215215
success: bool,
216-
error: int | None = None,
216+
error_num: int | None = None,
217217
error_msg: str | None = None,
218218
) -> None:
219219
"""Set the success value for a RunningWorkflowStep Record,
@@ -224,12 +224,7 @@ def get_instance(self, *, instance_id: str) -> tuple[dict[str, Any], int]:
224224
"""Get an Instance Record"""
225225
# For a RunningWorkflowStep Instance it should return:
226226
# {
227-
# "id": "instance-00000000-0000-0000-0000-000000000001",
228-
# "running_workflow_step": {
229-
# "id": "r-workflow-step-00000000-0000-0000-0000-000000000001",
230-
# "step": "step-1234",
231-
# },
232-
# [...],
227+
# "running_workflow_step_id": "r-workflow-step-00000000-0000-0000-0000-000000000001",
233228
# }
234229
# If not present an empty dictionary should be returned.
235230

workflow/workflow_engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,13 @@ def _set_step_error(
438438
self._wapi_adapter.set_running_workflow_step_done(
439439
running_workflow_step_id=r_wfsid,
440440
success=False,
441-
error=error,
441+
error_num=error,
442442
error_msg=error_msg,
443443
)
444444
# We must also set the running workflow as done (failed)
445445
self._wapi_adapter.set_running_workflow_done(
446446
running_workflow_id=r_wfid,
447447
success=False,
448-
error=error,
448+
error_num=error,
449449
error_msg=error_msg,
450450
)

0 commit comments

Comments
 (0)