2121from dapr .ext .workflow .dapr_workflow_client import DaprWorkflowClient
2222from durabletask import client
2323import durabletask .internal .orchestrator_service_pb2 as pb
24+ from grpc import StatusCode , RpcError
2425
2526mock_schedule_result = 'workflow001'
2627mock_raise_event_result = 'event001'
2930mock_resume_result = 'resume001'
3031mock_purge_result = 'purge001'
3132mock_instance_id = 'instance001'
33+ wf_exists = False
34+
35+ class SimulatedRpcError (RpcError ):
36+ def __init__ (self , code , details ):
37+ self ._code = code
38+ self ._details = details
39+
40+ def code (self ):
41+ return self ._code
42+
43+ def details (self ):
44+ return self ._details
3245
3346
3447class FakeTaskHubGrpcClient :
@@ -43,8 +56,13 @@ def schedule_new_orchestration(
4356 return mock_schedule_result
4457
4558 def get_orchestration_state (self , instance_id , fetch_payloads ):
59+ global wf_exists
60+ if not wf_exists :
61+ raise SimulatedRpcError (code = "UNKNOWN" , details = "no such instance exists" )
62+
4663 return self ._inner_get_orchestration_state (instance_id , client .OrchestrationStatus .PENDING )
4764
65+
4866 def wait_for_orchestration_start (self , instance_id , fetch_payloads , timeout ):
4967 return self ._inner_get_orchestration_state (instance_id , client .OrchestrationStatus .RUNNING )
5068
@@ -100,6 +118,13 @@ def test_client_functions(self):
100118 )
101119 assert actual_schedule_result == mock_schedule_result
102120
121+ actual_get_result = wfClient .get_workflow_state (instance_id = mock_instance_id ,
122+ fetch_payloads = True )
123+ assert actual_get_result is None
124+
125+
126+ global wf_exists
127+ wf_exists = True
103128 actual_get_result = wfClient .get_workflow_state (
104129 instance_id = mock_instance_id , fetch_payloads = True
105130 )
0 commit comments