Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit cbe19db

Browse files
committed
updated some goldens
1 parent 7264e63 commit cbe19db

File tree

34 files changed

+727
-88
lines changed

34 files changed

+727
-88
lines changed

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/async_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def transport(self) -> AssetServiceTransport:
170170
return self._client.transport
171171

172172
@property
173-
def api_endpoint(self):
173+
def api_endpoint(self) -> str:
174174
"""Return the API endpoint used by the client instance.
175175
176176
Returns:
@@ -3154,7 +3154,7 @@ async def sample_analyze_org_policy_governed_assets():
31543154

31553155
async def get_operation(
31563156
self,
3157-
request: Optional[operations_pb2.GetOperationRequest] = None,
3157+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
31583158
*,
31593159
retry: OptionalRetry = gapic_v1.method.DEFAULT,
31603160
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -3180,6 +3180,8 @@ async def get_operation(
31803180
# Create or coerce a protobuf request object.
31813181
# The request isn't a proto-plus wrapped type,
31823182
# so it must be constructed via keyword expansion.
3183+
if request is None:
3184+
request = {}
31833185
if isinstance(request, dict):
31843186
request = operations_pb2.GetOperationRequest(**request)
31853187

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ class AssetServiceClient(metaclass=AssetServiceClientMeta):
101101
"""Asset service definition."""
102102

103103
@staticmethod
104-
def _get_default_mtls_endpoint(api_endpoint):
104+
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
105105
"""Converts api endpoint to mTLS endpoint.
106106
107107
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
108108
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
109109
Args:
110110
api_endpoint (Optional[str]): the api endpoint to convert.
111111
Returns:
112-
str: converted mTLS api endpoint.
112+
Optional[str]: converted mTLS api endpoint.
113113
"""
114114
if not api_endpoint:
115115
return api_endpoint
@@ -119,6 +119,10 @@ def _get_default_mtls_endpoint(api_endpoint):
119119
)
120120

121121
m = mtls_endpoint_re.match(api_endpoint)
122+
if m is None:
123+
# could not parse api_endpoint; return as-is
124+
return api_endpoint
125+
122126
name, mtls, sandbox, googledomain = m.groups()
123127
if mtls or not googledomain:
124128
return api_endpoint
@@ -446,7 +450,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
446450
return client_cert_source
447451

448452
@staticmethod
449-
def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint):
453+
def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint) -> str:
450454
"""Return the API endpoint used by the client.
451455
452456
Args:
@@ -532,7 +536,7 @@ def _add_cred_info_for_auth_errors(
532536
error._details.append(json.dumps(cred_info))
533537

534538
@property
535-
def api_endpoint(self):
539+
def api_endpoint(self) -> str:
536540
"""Return the API endpoint used by the client instance.
537541
538542
Returns:
@@ -3576,7 +3580,7 @@ def __exit__(self, type, value, traceback):
35763580

35773581
def get_operation(
35783582
self,
3579-
request: Optional[operations_pb2.GetOperationRequest] = None,
3583+
request: Optional[Union[operations_pb2.GetOperationRequest, dict]] = None,
35803584
*,
35813585
retry: OptionalRetry = gapic_v1.method.DEFAULT,
35823586
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
@@ -3602,6 +3606,8 @@ def get_operation(
36023606
# Create or coerce a protobuf request object.
36033607
# The request isn't a proto-plus wrapped type,
36043608
# so it must be constructed via keyword expansion.
3609+
if request is None:
3610+
request = {}
36053611
if isinstance(request, dict):
36063612
request = operations_pb2.GetOperationRequest(**request)
36073613

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/transports/grpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
5555
elif isinstance(request, google.protobuf.message.Message):
5656
request_payload = MessageToJson(request)
5757
else:
58-
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
58+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
5959

6060
request_metadata = {
6161
key: value.decode("utf-8") if isinstance(value, bytes) else value
@@ -86,7 +86,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
8686
elif isinstance(result, google.protobuf.message.Message):
8787
response_payload = MessageToJson(result)
8888
else:
89-
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
89+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
9090
grpc_response = {
9191
"payload": response_payload,
9292
"metadata": metadata,

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def intercept_unary_unary(self, continuation, client_call_details, request
5959
elif isinstance(request, google.protobuf.message.Message):
6060
request_payload = MessageToJson(request)
6161
else:
62-
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
62+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
6363

6464
request_metadata = {
6565
key: value.decode("utf-8") if isinstance(value, bytes) else value
@@ -90,7 +90,7 @@ async def intercept_unary_unary(self, continuation, client_call_details, request
9090
elif isinstance(result, google.protobuf.message.Message):
9191
response_payload = MessageToJson(result)
9292
else:
93-
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
93+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
9494
grpc_response = {
9595
"payload": response_payload,
9696
"metadata": metadata,

tests/integration/goldens/asset/noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def mypy(session):
107107
"mypy",
108108
"-p",
109109
"google",
110+
"--check-untyped-defs",
111+
*session.posargs,
110112
)
111113

112114

tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ def test__get_default_mtls_endpoint():
114114
sandbox_endpoint = "example.sandbox.googleapis.com"
115115
sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com"
116116
non_googleapi = "api.example.com"
117+
custom_endpoint = ".custom"
117118

118119
assert AssetServiceClient._get_default_mtls_endpoint(None) is None
119120
assert AssetServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint
120121
assert AssetServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint
121122
assert AssetServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint
122123
assert AssetServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint
123124
assert AssetServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi
125+
assert AssetServiceClient._get_default_mtls_endpoint(custom_endpoint) == custom_endpoint
124126

125127
def test__read_environment_variables():
126128
assert AssetServiceClient._read_environment_variables() == (False, "auto", None)
@@ -18385,6 +18387,37 @@ async def test_get_operation_from_dict_async():
1838518387
)
1838618388
call.assert_called()
1838718389

18390+
def test_get_operation_flattened():
18391+
client = AssetServiceClient(
18392+
credentials=ga_credentials.AnonymousCredentials(),
18393+
)
18394+
# Mock the actual call within the gRPC stub, and fake the request.
18395+
with mock.patch.object(type(client.transport.get_operation), "__call__") as call:
18396+
# Designate an appropriate return value for the call.
18397+
call.return_value = operations_pb2.Operation()
18398+
18399+
client.get_operation()
18400+
# Establish that the underlying gRPC stub method was called.
18401+
assert len(call.mock_calls) == 1
18402+
_, args, _ = call.mock_calls[0]
18403+
assert args[0] == operations_pb2.GetOperationRequest()
18404+
@pytest.mark.asyncio
18405+
async def test_get_operation_flattened_async():
18406+
client = AssetServiceAsyncClient(
18407+
credentials=async_anonymous_credentials(),
18408+
)
18409+
# Mock the actual call within the gRPC stub, and fake the request.
18410+
with mock.patch.object(type(client.transport.get_operation), "__call__") as call:
18411+
# Designate an appropriate return value for the call.
18412+
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
18413+
operations_pb2.Operation()
18414+
)
18415+
await client.get_operation()
18416+
# Establish that the underlying gRPC stub method was called.
18417+
assert len(call.mock_calls) == 1
18418+
_, args, _ = call.mock_calls[0]
18419+
assert args[0] == operations_pb2.GetOperationRequest()
18420+
1838818421

1838918422
def test_transport_close_grpc():
1839018423
client = AssetServiceClient(

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/async_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def transport(self) -> IAMCredentialsTransport:
161161
return self._client.transport
162162

163163
@property
164-
def api_endpoint(self):
164+
def api_endpoint(self) -> str:
165165
"""Return the API endpoint used by the client instance.
166166
167167
Returns:

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ class IAMCredentialsClient(metaclass=IAMCredentialsClientMeta):
104104
"""
105105

106106
@staticmethod
107-
def _get_default_mtls_endpoint(api_endpoint):
107+
def _get_default_mtls_endpoint(api_endpoint) -> Optional[str]:
108108
"""Converts api endpoint to mTLS endpoint.
109109
110110
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
111111
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
112112
Args:
113113
api_endpoint (Optional[str]): the api endpoint to convert.
114114
Returns:
115-
str: converted mTLS api endpoint.
115+
Optional[str]: converted mTLS api endpoint.
116116
"""
117117
if not api_endpoint:
118118
return api_endpoint
@@ -122,6 +122,10 @@ def _get_default_mtls_endpoint(api_endpoint):
122122
)
123123

124124
m = mtls_endpoint_re.match(api_endpoint)
125+
if m is None:
126+
# could not parse api_endpoint; return as-is
127+
return api_endpoint
128+
125129
name, mtls, sandbox, googledomain = m.groups()
126130
if mtls or not googledomain:
127131
return api_endpoint
@@ -383,7 +387,7 @@ def _get_client_cert_source(provided_cert_source, use_cert_flag):
383387
return client_cert_source
384388

385389
@staticmethod
386-
def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint):
390+
def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint) -> str:
387391
"""Return the API endpoint used by the client.
388392
389393
Args:
@@ -469,7 +473,7 @@ def _add_cred_info_for_auth_errors(
469473
error._details.append(json.dumps(cred_info))
470474

471475
@property
472-
def api_endpoint(self):
476+
def api_endpoint(self) -> str:
473477
"""Return the API endpoint used by the client instance.
474478
475479
Returns:

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/transports/grpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
5252
elif isinstance(request, google.protobuf.message.Message):
5353
request_payload = MessageToJson(request)
5454
else:
55-
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
55+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
5656

5757
request_metadata = {
5858
key: value.decode("utf-8") if isinstance(value, bytes) else value
@@ -83,7 +83,7 @@ def intercept_unary_unary(self, continuation, client_call_details, request):
8383
elif isinstance(result, google.protobuf.message.Message):
8484
response_payload = MessageToJson(result)
8585
else:
86-
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
86+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
8787
grpc_response = {
8888
"payload": response_payload,
8989
"metadata": metadata,

tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/transports/grpc_asyncio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async def intercept_unary_unary(self, continuation, client_call_details, request
5656
elif isinstance(request, google.protobuf.message.Message):
5757
request_payload = MessageToJson(request)
5858
else:
59-
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
59+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)!r}"
6060

6161
request_metadata = {
6262
key: value.decode("utf-8") if isinstance(value, bytes) else value
@@ -87,7 +87,7 @@ async def intercept_unary_unary(self, continuation, client_call_details, request
8787
elif isinstance(result, google.protobuf.message.Message):
8888
response_payload = MessageToJson(result)
8989
else:
90-
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
90+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)!r}"
9191
grpc_response = {
9292
"payload": response_payload,
9393
"metadata": metadata,

0 commit comments

Comments
 (0)