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

Commit 03ec916

Browse files
committed
feat: Multiplexed sessions - Update _builders to use mock scoped credentials.
Signed-off-by: Taylor Curran <taylor.curran@improving.com>
1 parent d5181ae commit 03ec916

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/_builders.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from mock import create_autospec
1717
from typing import Mapping
1818

19+
from google.auth.credentials import Credentials, Scoped
1920
from google.cloud.spanner_dbapi import Connection
2021
from google.cloud.spanner_v1 import SpannerClient
2122
from google.cloud.spanner_v1.client import Client
@@ -92,6 +93,9 @@ def build_client(**kwargs: Mapping) -> Client:
9293
if "project" not in kwargs:
9394
kwargs["project"] = _PROJECT_ID
9495

96+
if "credentials" not in kwargs:
97+
kwargs["credentials"] = build_scoped_credentials()
98+
9599
return Client(**kwargs)
96100

97101

@@ -174,6 +178,15 @@ def build_logger() -> Logger:
174178
return create_autospec(Logger, instance=True)
175179

176180

181+
def build_scoped_credentials() -> Credentials:
182+
"""Builds and returns a mock scoped credentials for testing."""
183+
184+
class _ScopedCredentials(Credentials, Scoped):
185+
pass
186+
187+
return create_autospec(spec=_ScopedCredentials, instance=True)
188+
189+
177190
def build_spanner_api() -> SpannerClient:
178191
"""Builds and returns a mock Spanner Client API for testing using the given arguments.
179192
Commonly used methods are mocked to return default values."""

0 commit comments

Comments
 (0)