|
2 | 2 | import os |
3 | 3 | import re |
4 | 4 | from datetime import timedelta |
5 | | -from importlib import import_module |
6 | 5 | from typing import Any, Callable, Dict, Mapping, Tuple, Type |
7 | 6 |
|
8 | 7 | import google.protobuf.empty_pb2 |
9 | 8 | import google.protobuf.message |
10 | 9 | import google.protobuf.symbol_database |
11 | 10 | import grpc |
12 | 11 | import pytest |
13 | | -from google.protobuf.descriptor import MethodDescriptor |
| 12 | +from google.protobuf.descriptor import FileDescriptor, MethodDescriptor |
14 | 13 |
|
15 | 14 | import temporalio |
16 | 15 | import temporalio.api.cloud.cloudservice.v1 |
| 16 | +import temporalio.api.cloud.cloudservice.v1.service_pb2 |
17 | 17 | import temporalio.api.errordetails.v1 |
18 | 18 | import temporalio.api.operatorservice.v1 |
| 19 | +import temporalio.api.operatorservice.v1.service_pb2 |
19 | 20 | import temporalio.api.testservice.v1 |
| 21 | +import temporalio.api.testservice.v1.service_pb2 |
20 | 22 | import temporalio.api.workflowservice.v1 |
| 23 | +import temporalio.api.workflowservice.v1.service_pb2 |
| 24 | +import temporalio.bridge.proto.health.v1.health_pb2 |
21 | 25 | import temporalio.service |
22 | 26 | from temporalio.client import Client |
23 | 27 | from temporalio.testing import WorkflowEnvironment |
@@ -202,37 +206,36 @@ async def test_method( |
202 | 206 | ), f"Unexpected unknown-RPC error for {target_service_name}.{method_name}: {err}" |
203 | 207 |
|
204 | 208 | 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 |
206 | 210 | ): |
207 | 211 | # 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] |
210 | 213 |
|
211 | 214 | for method_descriptor in service_descriptor.methods: |
212 | 215 | await test_method(target_service_name, method_descriptor) |
213 | 216 |
|
214 | 217 | await test_service( |
215 | | - proto_module="temporalio.api.workflowservice.v1.service_pb2", |
| 218 | + proto_module=temporalio.api.workflowservice.v1.service_pb2.DESCRIPTOR, |
216 | 219 | proto_service="WorkflowService", |
217 | 220 | target_service_name="workflow_service", |
218 | 221 | ) |
219 | 222 | await test_service( |
220 | | - proto_module="temporalio.api.operatorservice.v1.service_pb2", |
| 223 | + proto_module=temporalio.api.operatorservice.v1.service_pb2.DESCRIPTOR, |
221 | 224 | proto_service="OperatorService", |
222 | 225 | target_service_name="operator_service", |
223 | 226 | ) |
224 | 227 | await test_service( |
225 | | - proto_module="temporalio.api.cloud.cloudservice.v1.service_pb2", |
| 228 | + proto_module=temporalio.api.cloud.cloudservice.v1.service_pb2.DESCRIPTOR, |
226 | 229 | proto_service="CloudService", |
227 | 230 | target_service_name="cloud_service", |
228 | 231 | ) |
229 | 232 | await test_service( |
230 | | - proto_module="temporalio.api.testservice.v1.service_pb2", |
| 233 | + proto_module=temporalio.api.testservice.v1.service_pb2.DESCRIPTOR, |
231 | 234 | proto_service="TestService", |
232 | 235 | target_service_name="test_service", |
233 | 236 | ) |
234 | 237 | await test_service( |
235 | | - proto_module="temporalio.bridge.proto.health.v1.health_pb2", |
| 238 | + proto_module=temporalio.bridge.proto.health.v1.health_pb2.DESCRIPTOR, |
236 | 239 | proto_service="Health", |
237 | 240 | target_service_name="health_service", |
238 | 241 | ) |
0 commit comments