Skip to content

Commit

Permalink
fixed broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed May 9, 2024
1 parent 144c98e commit e9c5581
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/unit/v2_client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ def test_client_constructor_w_emulator_host():
from google.cloud.environment_vars import BIGTABLE_EMULATOR
from google.cloud.bigtable.client import _DEFAULT_BIGTABLE_EMULATOR_CLIENT
from google.cloud.bigtable.client import _GRPC_CHANNEL_OPTIONS
import grpc

emulator_host = "localhost:8081"
with mock.patch("os.environ", {BIGTABLE_EMULATOR: emulator_host}):
with mock.patch("grpc.insecure_channel") as factory:
channel = grpc.insecure_channel('no-host')
with mock.patch("grpc.insecure_channel", return_value=channel) as factory:
factory.return_value = channel
client = _make_client()
# don't test local_composite_credentials
# client._local_composite_credentials = lambda: credentials
Expand All @@ -195,10 +198,12 @@ def test_client_constructor_w_emulator_host():
def test_client_constructor_w_emulator_host_w_project():
from google.cloud.environment_vars import BIGTABLE_EMULATOR
from google.cloud.bigtable.client import _GRPC_CHANNEL_OPTIONS
import grpc

emulator_host = "localhost:8081"
with mock.patch("os.environ", {BIGTABLE_EMULATOR: emulator_host}):
with mock.patch("grpc.insecure_channel") as factory:
channel = grpc.insecure_channel('no-host')
with mock.patch("grpc.insecure_channel", return_value=channel) as factory:
client = _make_client(project=PROJECT)
# channels are formed when needed, so access a client
# create a gapic channel
Expand All @@ -216,11 +221,13 @@ def test_client_constructor_w_emulator_host_w_credentials():
from google.cloud.environment_vars import BIGTABLE_EMULATOR
from google.cloud.bigtable.client import _DEFAULT_BIGTABLE_EMULATOR_CLIENT
from google.cloud.bigtable.client import _GRPC_CHANNEL_OPTIONS
import grpc

emulator_host = "localhost:8081"
credentials = _make_credentials()
with mock.patch("os.environ", {BIGTABLE_EMULATOR: emulator_host}):
with mock.patch("grpc.insecure_channel") as factory:
channel = grpc.insecure_channel('no-host')
with mock.patch("grpc.insecure_channel", return_value=channel) as factory:
client = _make_client(credentials=credentials)
# channels are formed when needed, so access a client
# create a gapic channel
Expand Down

0 comments on commit e9c5581

Please sign in to comment.