Skip to content

Commit 5fd9ae9

Browse files
Extends test
Signed-off-by: Elena Kolevska <[email protected]>
1 parent 01c75b4 commit 5fd9ae9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

ext/dapr-ext-workflow/tests/test_workflow_client.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
mock_resume_result = 'resume001'
3131
mock_purge_result = 'purge001'
3232
mock_instance_id = 'instance001'
33-
wf_exists = False
33+
wf_status = 'not-found'
3434

3535

3636
class SimulatedRpcError(RpcError):
@@ -57,11 +57,15 @@ def schedule_new_orchestration(
5757
return mock_schedule_result
5858

5959
def get_orchestration_state(self, instance_id, fetch_payloads):
60-
global wf_exists
61-
if not wf_exists:
60+
global wf_status
61+
if wf_status == 'not-found':
6262
raise SimulatedRpcError(code='UNKNOWN', details='no such instance exists')
63-
64-
return self._inner_get_orchestration_state(instance_id, client.OrchestrationStatus.PENDING)
63+
elif wf_status == 'found':
64+
return self._inner_get_orchestration_state(
65+
instance_id, client.OrchestrationStatus.PENDING
66+
)
67+
else:
68+
raise SimulatedRpcError(code='UNKNOWN', details='unknown error')
6569

6670
def wait_for_orchestration_start(self, instance_id, fetch_payloads, timeout):
6771
return self._inner_get_orchestration_state(instance_id, client.OrchestrationStatus.RUNNING)
@@ -118,13 +122,20 @@ def test_client_functions(self):
118122
)
119123
assert actual_schedule_result == mock_schedule_result
120124

125+
global wf_status
126+
wf_status = 'not-found'
121127
actual_get_result = wfClient.get_workflow_state(
122128
instance_id=mock_instance_id, fetch_payloads=True
123129
)
124130
assert actual_get_result is None
125131

126-
global wf_exists
127-
wf_exists = True
132+
wf_status = 'error'
133+
with self.assertRaises(RpcError):
134+
wfClient.get_workflow_state(instance_id=mock_instance_id, fetch_payloads=True)
135+
136+
assert actual_get_result is None
137+
138+
wf_status = 'found'
128139
actual_get_result = wfClient.get_workflow_state(
129140
instance_id=mock_instance_id, fetch_payloads=True
130141
)

0 commit comments

Comments
 (0)