7
7
from iwf .iwf_api .models import (
8
8
PersistenceLoadingPolicy ,
9
9
PersistenceLoadingType ,
10
- WorkflowStateOptions as IdlWorkflowStateOptions , RetryPolicy ,
10
+ WorkflowStateOptions as IdlWorkflowStateOptions ,
11
+ RetryPolicy ,
11
12
WaitUntilApiFailurePolicy ,
12
13
)
13
14
from iwf .tests .worker_server import registry
14
- from iwf .tests .workflows .state_options_workflow import (StateOptionsWorkflow1 ,
15
- StateOptionsWorkflow2 )
15
+ from iwf .tests .workflows .state_options_workflow import (
16
+ StateOptionsWorkflow1 ,
17
+ StateOptionsWorkflow2 ,
18
+ )
16
19
from iwf .workflow_options import WorkflowOptions
17
20
from iwf .workflow_state_options import WorkflowStateOptions , _to_idl_state_options
18
21
from ..errors import WorkflowFailed
@@ -44,6 +47,7 @@ def test_convert_to_idl(self):
44
47
assert non_empty .state_id == "state-id-2"
45
48
46
49
"""Test that proceed_to_execute_when_wait_until_retry_exhausted correctly handles both enum values."""
50
+
47
51
def test_proceed_to_execute_when_wait_until_retry_exhausted (self ):
48
52
retry_policy = RetryPolicy (maximum_attempts = 1 )
49
53
@@ -53,22 +57,29 @@ def test_proceed_to_execute_when_wait_until_retry_exhausted(self):
53
57
wait_until_api_retry_policy = retry_policy ,
54
58
)
55
59
result_proceed = _to_idl_state_options (False , options_proceed , {})
56
- assert result_proceed .wait_until_api_failure_policy == WaitUntilApiFailurePolicy .PROCEED_ON_FAILURE
60
+ assert (
61
+ result_proceed .wait_until_api_failure_policy
62
+ == WaitUntilApiFailurePolicy .PROCEED_ON_FAILURE
63
+ )
57
64
58
65
# Test FAIL_WORKFLOW_ON_FAILURE
59
66
options_fail = WorkflowStateOptions (
60
67
proceed_to_execute_when_wait_until_retry_exhausted = WaitUntilApiFailurePolicy .FAIL_WORKFLOW_ON_FAILURE ,
61
68
wait_until_api_retry_policy = retry_policy ,
62
69
)
63
70
result_fail = _to_idl_state_options (False , options_fail , {})
64
- assert result_fail .wait_until_api_failure_policy == WaitUntilApiFailurePolicy .FAIL_WORKFLOW_ON_FAILURE
71
+ assert (
72
+ result_fail .wait_until_api_failure_policy
73
+ == WaitUntilApiFailurePolicy .FAIL_WORKFLOW_ON_FAILURE
74
+ )
65
75
66
76
# Test with None/unset value
67
77
options = WorkflowStateOptions ()
68
78
result = _to_idl_state_options (False , options , {})
69
79
# By default, wait_until_api_failure_policy should not be set when proceed_to_execute_when_wait_until_retry_exhausted is None
70
80
# The IWF service will use FAIL_WORKFLOW_ON_FAILURE by default
71
81
from iwf .iwf_api .types import Unset
82
+
72
83
self .assertTrue (isinstance (result .wait_until_api_failure_policy , Unset ))
73
84
74
85
def test_proceed_on_failure (self ):
@@ -82,10 +93,7 @@ def test_proceed_on_failure(self):
82
93
)
83
94
output = self .client .wait_for_workflow_completion (wf_id )
84
95
85
- assert (
86
- output
87
- == "InitState1_execute_completed"
88
- )
96
+ assert output == "InitState1_execute_completed"
89
97
90
98
def test_fail_workflow_on_failure (self ):
91
99
wf_id = f"{ inspect .currentframe ().f_code .co_name } -{ time .time_ns ()} "
0 commit comments