Skip to content

Commit 257395c

Browse files
committed
Try out reference descriptors directly rather than using importlib
1 parent 8a35b88 commit 257395c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tests/test_service.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
import os
33
import re
44
from datetime import timedelta
5-
from importlib import import_module
65
from typing import Any, Callable, Dict, Mapping, Tuple, Type
76

87
import google.protobuf.empty_pb2
98
import google.protobuf.message
109
import google.protobuf.symbol_database
1110
import grpc
1211
import pytest
13-
from google.protobuf.descriptor import MethodDescriptor
12+
from google.protobuf.descriptor import FileDescriptor, MethodDescriptor
1413

1514
import temporalio
1615
import temporalio.api.cloud.cloudservice.v1
16+
import temporalio.api.cloud.cloudservice.v1.service_pb2
1717
import temporalio.api.errordetails.v1
1818
import temporalio.api.operatorservice.v1
19+
import temporalio.api.operatorservice.v1.service_pb2
1920
import temporalio.api.testservice.v1
21+
import temporalio.api.testservice.v1.service_pb2
2022
import temporalio.api.workflowservice.v1
23+
import temporalio.api.workflowservice.v1.service_pb2
24+
import temporalio.bridge.proto.health.v1.health_pb2
2125
import temporalio.service
2226
from temporalio.client import Client
2327
from temporalio.testing import WorkflowEnvironment
@@ -202,37 +206,36 @@ async def test_method(
202206
), f"Unexpected unknown-RPC error for {target_service_name}.{method_name}: {err}"
203207

204208
async def test_service(
205-
*, proto_module: str, proto_service: str, target_service_name: str
209+
*, proto_module: FileDescriptor, proto_service: str, target_service_name: str
206210
):
207211
# load the module and test each method of the specified service
208-
module = import_module(proto_module)
209-
service_descriptor = module.DESCRIPTOR.services_by_name[proto_service]
212+
service_descriptor = proto_module.services_by_name[proto_service]
210213

211214
for method_descriptor in service_descriptor.methods:
212215
await test_method(target_service_name, method_descriptor)
213216

214217
await test_service(
215-
proto_module="temporalio.api.workflowservice.v1.service_pb2",
218+
proto_module=temporalio.api.workflowservice.v1.service_pb2.DESCRIPTOR,
216219
proto_service="WorkflowService",
217220
target_service_name="workflow_service",
218221
)
219222
await test_service(
220-
proto_module="temporalio.api.operatorservice.v1.service_pb2",
223+
proto_module=temporalio.api.operatorservice.v1.service_pb2.DESCRIPTOR,
221224
proto_service="OperatorService",
222225
target_service_name="operator_service",
223226
)
224227
await test_service(
225-
proto_module="temporalio.api.cloud.cloudservice.v1.service_pb2",
228+
proto_module=temporalio.api.cloud.cloudservice.v1.service_pb2.DESCRIPTOR,
226229
proto_service="CloudService",
227230
target_service_name="cloud_service",
228231
)
229232
await test_service(
230-
proto_module="temporalio.api.testservice.v1.service_pb2",
233+
proto_module=temporalio.api.testservice.v1.service_pb2.DESCRIPTOR,
231234
proto_service="TestService",
232235
target_service_name="test_service",
233236
)
234237
await test_service(
235-
proto_module="temporalio.bridge.proto.health.v1.health_pb2",
238+
proto_module=temporalio.bridge.proto.health.v1.health_pb2.DESCRIPTOR,
236239
proto_service="Health",
237240
target_service_name="health_service",
238241
)

0 commit comments

Comments
 (0)