1+ from datetime import timedelta
12import pytest
2-
33from cadence .api .v1 .service_domain_pb2 import DescribeDomainRequest , DescribeDomainResponse
4+ from cadence .api .v1 .service_workflow_pb2 import DescribeWorkflowExecutionRequest
5+ from cadence .api .v1 .common_pb2 import WorkflowExecution
46from cadence .error import EntityNotExistsError
57from tests .integration_tests .helper import CadenceHelper , DOMAIN_NAME
68
@@ -16,3 +18,123 @@ async def test_domain_not_exists(helper: CadenceHelper):
1618 with pytest .raises (EntityNotExistsError ):
1719 async with helper .client () as client :
1820 await client .domain_stub .DescribeDomain (DescribeDomainRequest (name = "unknown-domain" ))
21+
22+ # Worker Stub Tests
23+
24+ @pytest .mark .usefixtures ("helper" )
25+ async def test_worker_stub_accessible (helper : CadenceHelper ):
26+ """Test that worker_stub is properly initialized and accessible."""
27+ async with helper .client () as client :
28+ assert client .worker_stub is not None
29+ # Verify it's the correct type
30+ from cadence .api .v1 .service_worker_pb2_grpc import WorkerAPIStub
31+ assert isinstance (client .worker_stub , WorkerAPIStub )
32+
33+ # Workflow Stub Tests
34+
35+ @pytest .mark .usefixtures ("helper" )
36+ async def test_workflow_stub_accessible (helper : CadenceHelper ):
37+ """Test that workflow_stub is properly initialized and accessible."""
38+ async with helper .client () as client :
39+ assert client .workflow_stub is not None
40+ # Verify it's the correct type
41+ from cadence .api .v1 .service_workflow_pb2_grpc import WorkflowAPIStub
42+ assert isinstance (client .workflow_stub , WorkflowAPIStub )
43+
44+ @pytest .mark .usefixtures ("helper" )
45+ async def test_workflow_stub_start_workflow (helper : CadenceHelper ):
46+ """Test starting a workflow execution via workflow_stub.
47+
48+ This test verifies that we can start a workflow execution using the
49+ client's start_workflow method, which uses workflow_stub internally.
50+ """
51+ async with helper .client () as client :
52+ # Start a simple workflow
53+ execution = await client .start_workflow (
54+ "test-workflow-type" ,
55+ task_list = "test-task-list" ,
56+ execution_start_to_close_timeout = timedelta (minutes = 5 ),
57+ workflow_id = "test-workflow-id-123" ,
58+ )
59+
60+ # Verify we got a valid execution response
61+ assert execution is not None
62+ assert execution .workflow_id == "test-workflow-id-123"
63+ assert execution .run_id is not None
64+ assert len (execution .run_id ) > 0
65+
66+ @pytest .mark .usefixtures ("helper" )
67+ async def test_workflow_stub_describe_workflow (helper : CadenceHelper ):
68+ """Test describing a workflow execution via workflow_stub.
69+
70+ This test verifies that we can query workflow execution details after
71+ starting a workflow.
72+ """
73+ async with helper .client () as client :
74+ # First start a workflow
75+ execution = await client .start_workflow (
76+ "test-workflow-type-describe" ,
77+ task_list = "test-task-list-describe" ,
78+ execution_start_to_close_timeout = timedelta (minutes = 5 ),
79+ workflow_id = "test-workflow-describe-456" ,
80+ )
81+
82+ # Now describe the workflow execution
83+ describe_request = DescribeWorkflowExecutionRequest (
84+ domain = DOMAIN_NAME ,
85+ workflow_execution = WorkflowExecution (
86+ workflow_id = execution .workflow_id ,
87+ run_id = execution .run_id ,
88+ ),
89+ )
90+
91+ response = await client .workflow_stub .DescribeWorkflowExecution (describe_request )
92+
93+ # Print the run_id for debugging
94+ print (f"Workflow run_id: { execution .run_id } " )
95+
96+ # Verify we got a valid response
97+ assert response is not None
98+ assert response .workflow_execution_info is not None
99+ assert response .workflow_execution_info .workflow_execution .workflow_id == execution .workflow_id
100+ assert response .workflow_execution_info .workflow_execution .run_id == execution .run_id
101+
102+ # Combined Test
103+
104+ @pytest .mark .usefixtures ("helper" )
105+ async def test_all_stubs_accessible (helper : CadenceHelper ):
106+ """Test that all three stubs (domain, worker, workflow) are accessible.
107+
108+ This is a comprehensive connectivity test that verifies the client
109+ can access all three main API stubs.
110+ """
111+ async with helper .client () as client :
112+ # Verify all stubs are initialized
113+ assert client .domain_stub is not None
114+ assert client .worker_stub is not None
115+ assert client .workflow_stub is not None
116+
117+ # Verify they are the correct types
118+ from cadence .api .v1 .service_domain_pb2_grpc import DomainAPIStub
119+ from cadence .api .v1 .service_worker_pb2_grpc import WorkerAPIStub
120+ from cadence .api .v1 .service_workflow_pb2_grpc import WorkflowAPIStub
121+
122+ assert isinstance (client .domain_stub , DomainAPIStub )
123+ assert isinstance (client .worker_stub , WorkerAPIStub )
124+ assert isinstance (client .workflow_stub , WorkflowAPIStub )
125+
126+ # Test basic connectivity with each stub
127+ # Domain stub - describe domain
128+ domain_response = await client .domain_stub .DescribeDomain (
129+ DescribeDomainRequest (name = DOMAIN_NAME )
130+ )
131+ assert domain_response .domain .name == DOMAIN_NAME
132+
133+ # Workflow stub - start workflow
134+ execution = await client .start_workflow (
135+ "connectivity-test-workflow" ,
136+ task_list = "connectivity-test-task-list" ,
137+ execution_start_to_close_timeout = timedelta (minutes = 5 ),
138+ workflow_id = "connectivity-test-workflow-789" ,
139+ )
140+ assert execution .workflow_id == "connectivity-test-workflow-789"
0 commit comments