3030mock_resume_result = 'resume001'
3131mock_purge_result = 'purge001'
3232mock_instance_id = 'instance001'
33- wf_exists = False
33+ wf_status = 'not-found'
3434
3535
3636class 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