Skip to content

Commit fd4a4dd

Browse files
committed
fix(generator): add coverage pragma comments for fallback path and mtls error raise, and update goldens
1 parent 0ad5329 commit fd4a4dd

22 files changed

Lines changed: 22 additions & 22 deletions

File tree

packages/gapic-generator/gapic/templates/%namespace/%name_%version/%sub/_compat.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ try:
1010
get_api_endpoint,
1111
get_universe_domain,
1212
)
13-
except ImportError:
13+
except ImportError: # pragma: NO COVER
1414
# TODO: Remove these fallbacks when google-api-core >= 2.18.0 is the minimum required version.
1515

1616
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:

packages/gapic-generator/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
314314
api_endpoint = api_endpoint_opt
315315
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
316316
if cls.DEFAULT_MTLS_ENDPOINT is None:
317-
raise MutualTLSChannelError("mTLS endpoint is not available.")
317+
raise MutualTLSChannelError("mTLS endpoint is not available.") # pragma: NO COVER
318318
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
319319
else:
320320
api_endpoint = cls.DEFAULT_ENDPOINT

packages/gapic-generator/tests/integration/goldens/asset/google/cloud/asset_v1/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
get_api_endpoint,
2323
get_universe_domain,
2424
)
25-
except ImportError:
25+
except ImportError: # pragma: NO COVER
2626
# TODO: Remove these fallbacks when google-api-core >= 2.18.0 is the minimum required version.
2727

2828
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:

packages/gapic-generator/tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
372372
api_endpoint = api_endpoint_opt
373373
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
374374
if cls.DEFAULT_MTLS_ENDPOINT is None:
375-
raise MutualTLSChannelError("mTLS endpoint is not available.")
375+
raise MutualTLSChannelError("mTLS endpoint is not available.") # pragma: NO COVER
376376
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
377377
else:
378378
api_endpoint = cls.DEFAULT_ENDPOINT

packages/gapic-generator/tests/integration/goldens/credentials/google/iam/credentials_v1/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
get_api_endpoint,
2323
get_universe_domain,
2424
)
25-
except ImportError:
25+
except ImportError: # pragma: NO COVER
2626
# TODO: Remove these fallbacks when google-api-core >= 2.18.0 is the minimum required version.
2727

2828
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:

packages/gapic-generator/tests/integration/goldens/credentials/google/iam/credentials_v1/services/iam_credentials/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
309309
api_endpoint = api_endpoint_opt
310310
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
311311
if cls.DEFAULT_MTLS_ENDPOINT is None:
312-
raise MutualTLSChannelError("mTLS endpoint is not available.")
312+
raise MutualTLSChannelError("mTLS endpoint is not available.") # pragma: NO COVER
313313
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
314314
else:
315315
api_endpoint = cls.DEFAULT_ENDPOINT

packages/gapic-generator/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
get_api_endpoint,
2323
get_universe_domain,
2424
)
25-
except ImportError:
25+
except ImportError: # pragma: NO COVER
2626
# TODO: Remove these fallbacks when google-api-core >= 2.18.0 is the minimum required version.
2727

2828
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:

packages/gapic-generator/tests/integration/goldens/eventarc/google/cloud/eventarc_v1/services/eventarc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
492492
api_endpoint = api_endpoint_opt
493493
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
494494
if cls.DEFAULT_MTLS_ENDPOINT is None:
495-
raise MutualTLSChannelError("mTLS endpoint is not available.")
495+
raise MutualTLSChannelError("mTLS endpoint is not available.") # pragma: NO COVER
496496
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
497497
else:
498498
api_endpoint = cls.DEFAULT_ENDPOINT

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
get_api_endpoint,
2323
get_universe_domain,
2424
)
25-
except ImportError:
25+
except ImportError: # pragma: NO COVER
2626
# TODO: Remove these fallbacks when google-api-core >= 2.18.0 is the minimum required version.
2727

2828
def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:

packages/gapic-generator/tests/integration/goldens/logging/google/cloud/logging_v2/services/config_service_v2/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_optio
368368
api_endpoint = api_endpoint_opt
369369
elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source):
370370
if cls.DEFAULT_MTLS_ENDPOINT is None:
371-
raise MutualTLSChannelError("mTLS endpoint is not available.")
371+
raise MutualTLSChannelError("mTLS endpoint is not available.") # pragma: NO COVER
372372
api_endpoint = cls.DEFAULT_MTLS_ENDPOINT
373373
else:
374374
api_endpoint = cls.DEFAULT_ENDPOINT

0 commit comments

Comments
 (0)