Skip to content

Commit b5204b3

Browse files
committed
fix(generator): update goldens for routing centralization
1 parent a89c8ca commit b5204b3

18 files changed

Lines changed: 5414 additions & 40 deletions

File tree

packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ def set_event_loop():
158158

159159
def test__read_environment_variables():
160160
assert {{ service.client_name }}._read_environment_variables() == (False, "auto", None)
161-
161+
162162
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
163163
assert {{ service.client_name }}._read_environment_variables() == (True, "auto", None)
164-
164+
165165
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}):
166166
assert {{ service.client_name }}._read_environment_variables() == (False, "auto", None)
167-
167+
168168
with mock.patch.dict(
169169
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
170170
):
@@ -184,10 +184,10 @@ def test__read_environment_variables():
184184

185185
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
186186
assert {{ service.client_name }}._read_environment_variables() == (False, "never", None)
187-
187+
188188
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}):
189189
assert {{ service.client_name }}._read_environment_variables() == (False, "always", None)
190-
190+
191191
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}):
192192
assert {{ service.client_name }}._read_environment_variables() == (False, "auto", None)
193193

@@ -277,7 +277,7 @@ def test_use_client_cert_effective():
277277
assert {{ service.client_name }}._use_client_cert_effective() is False
278278

279279
# Test case 12: Test when `should_use_client_cert` is available and the
280-
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
280+
# `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is unset. Also,
281281
# the GOOGLE_API_CONFIG environment variable is unset.
282282
if hasattr(google.auth.transport.mtls, "should_use_client_cert"):
283283
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": ""}):
@@ -287,7 +287,7 @@ def test_use_client_cert_effective():
287287
def test__get_client_cert_source():
288288
mock_provided_cert_source = mock.Mock()
289289
mock_default_cert_source = mock.Mock()
290-
290+
291291
assert {{ service.client_name }}._get_client_cert_source(None, False) is None
292292
assert {{ service.client_name }}._get_client_cert_source(mock_provided_cert_source, False) is None
293293
assert {{ service.client_name }}._get_client_cert_source(mock_provided_cert_source, True) == mock_provided_cert_source
@@ -819,7 +819,7 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
819819
)
820820
assert api_endpoint == mock_api_endpoint
821821
assert cert_source is None
822-
822+
823823
# Test cases for mTLS enablement when GOOGLE_API_USE_CLIENT_CERTIFICATE is unset.
824824
test_cases = [
825825
(
@@ -852,7 +852,7 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
852852
config_filename = "mock_certificate_config.json"
853853
config_file_content = json.dumps(config_data)
854854
m = mock.mock_open(read_data=config_file_content)
855-
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
855+
with mock.patch("builtins.open", m):
856856
with mock.patch.dict(
857857
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
858858
):
@@ -881,10 +881,10 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
881881
},
882882
},
883883
mock_client_cert_source,
884-
),
884+
),
885885
(
886886
# With workloads not present in config, mTLS is disabled.
887-
{
887+
{
888888
"version": 1,
889889
"cert_configs": {},
890890
},
@@ -899,7 +899,7 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
899899
config_filename = "mock_certificate_config.json"
900900
config_file_content = json.dumps(config_data)
901901
m = mock.mock_open(read_data=config_file_content)
902-
with mock.patch("builtins.open", m), mock.patch("os.path.exists", side_effect=lambda path: os.path.basename(path) == config_filename):
902+
with mock.patch("builtins.open", m):
903903
with mock.patch.dict(
904904
os.environ, {"GOOGLE_API_CERTIFICATE_CONFIG": config_filename}
905905
):
@@ -946,7 +946,7 @@ def test_{{ service.client_name|snake_case }}_get_mtls_endpoint_and_cert_source(
946946
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
947947
with pytest.raises(MutualTLSChannelError) as excinfo:
948948
client_class.get_mtls_endpoint_and_cert_source()
949-
949+
950950
assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`"
951951

952952
@pytest.mark.parametrize("client_class", [
@@ -1011,7 +1011,7 @@ def test_{{ service.client_name|snake_case }}_client_api_endpoint(client_class):
10111011
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}):
10121012
client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials())
10131013
assert client.api_endpoint == default_endpoint
1014-
1014+
10151015

10161016
@pytest.mark.parametrize("client_class,transport_class,transport_name", [
10171017
{% if 'grpc' in opts.transport %}

packages/gapic-generator/noxfile.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@
3636

3737
showcase_version = os.environ.get("SHOWCASE_VERSION", "0.35.0")
3838
ADS_TEMPLATES = path.join(path.dirname(__file__), "gapic", "ads-templates")
39-
CURRENT_DIRECTORY = Path(__file__).parent.absolute()
40-
# Path to the centralized mypy configuration file at the repository root.
41-
# Search upwards to support running nox from both monorepo packages and integration test goldens.
42-
MYPY_CONFIG_FILE = next(
43-
(
44-
str(p / "mypy.ini")
45-
for p in CURRENT_DIRECTORY.parents
46-
if (p / "mypy.ini").exists()
47-
),
48-
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
49-
)
50-
5139
RUFF_VERSION = "ruff==0.14.14"
5240
LINT_PATHS = ["docs", "gapic", "tests", "test_utils", "noxfile.py", "setup.py"]
5341
# Ruff uses globs for excludes (different from Black's regex)
@@ -744,7 +732,7 @@ def mypy(session):
744732
"click==8.1.3",
745733
)
746734
session.install(".")
747-
session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "gapic")
735+
session.run("mypy", "-p", "gapic")
748736

749737

750738
@nox.session(python=NEWEST_PYTHON)
@@ -756,7 +744,7 @@ def lint(session):
756744
"""
757745

758746
# TODO(https://github.com/googleapis/google-cloud-python/issues/16186):
759-
# SKIP: This session was not enforced in the standalone (split) repo
747+
# SKIP: This session was not enforced in the standalone (split) repo
760748
# and is disabled here to ensure a "move-only" migration.
761749
session.skip(
762750
"Linting was not enforced in the split repo. "
@@ -786,11 +774,9 @@ def lint(session):
786774
@nox.session(python=NEWEST_PYTHON)
787775
def lint_setup_py(session):
788776
# TODO(https://github.com/googleapis/google-cloud-python/issues/16186):
789-
# SKIP: This session was not enforced in the standalone (split) repo
777+
# SKIP: This session was not enforced in the standalone (split) repo
790778
# and is disabled here to ensure a "move-only" migration.
791-
session.skip(
792-
"Skipping now to avoid changing code during migration. See Issue #16186"
793-
)
779+
session.skip("Skipping now to avoid changing code during migration. See Issue #16186")
794780

795781

796782
@nox.session(python="3.10")
@@ -865,11 +851,9 @@ def prerelease_deps(session, protobuf_implementation):
865851
"""
866852
Run all tests with pre-release versions of dependencies installed.
867853
"""
868-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16184):
854+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16184):
869855
# Implement pre-release dependency logic to test against upcoming runtime changes.
870-
session.skip(
871-
"prerelease_deps session is not yet implemented for gapic-generator-python."
872-
)
856+
session.skip("prerelease_deps session is not yet implemented for gapic-generator-python.")
873857

874858

875859
@nox.session(python=NEWEST_PYTHON)
@@ -879,8 +863,6 @@ def prerelease_deps(session, protobuf_implementation):
879863
)
880864
def core_deps_from_source(session, protobuf_implementation):
881865
"""Run all tests with core dependencies installed from source."""
882-
# TODO(https://github.com/googleapis/google-cloud-python/issues/16185):
866+
# TODO(https://github.com/googleapis/google-cloud-python/issues/16185):
883867
# Implement logic to install core packages directly from the mono-repo directories.
884-
session.skip(
885-
"core_deps_from_source session is not yet implemented for gapic-generator-python."
886-
)
868+
session.skip("core_deps_from_source session is not yet implemented for gapic-generator-python.")

0 commit comments

Comments
 (0)