Skip to content

Commit

Permalink
fix: Test failures due to grpcio changes
Browse files Browse the repository at this point in the history
* Failures can be found in googleapis/python-api-common-protos#223
  • Loading branch information
mukund-ananthu committed May 29, 2024
1 parent ff229a5 commit 272e34e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions tests/unit/pubsub_v1/publisher/test_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,19 @@ def test_init_w_api_endpoint(creds):
client_options = {"api_endpoint": "testendpoint.google.com"}
client = publisher.Client(client_options=client_options, credentials=creds)

assert (client._transport.grpc_channel._channel.target()).decode(
"utf-8"
) == "testendpoint.google.com:443"
endpoint = client._transport.grpc_channel._channel.target().decode("utf-8")
if grpc.__version__ >= "1.63.0":
assert endpoint == "dns:///testendpoint.google.com:443"
else:
assert endpoint == "testendpoint.google.com:443"


def test_init_w_empty_client_options(creds):
client = publisher.Client(client_options={}, credentials=creds)

assert (client._transport.grpc_channel._channel.target()).decode(
"utf-8"
) == publisher_client.PublisherClient.SERVICE_ADDRESS
) == ()"dns:///pubsub.googleapis.com:443"


def test_init_client_options_pass_through():
Expand Down Expand Up @@ -182,7 +184,7 @@ def test_init_emulator(monkeypatch):
# Sadly, there seems to be no good way to do this without poking at
# the private API of gRPC.
channel = client._transport.publish._channel
assert channel.target().decode("utf8") == "/foo/bar:123"
assert channel.target().decode("utf8") == "dns:////foo/bar:123"


def test_message_ordering_enabled(creds):
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/pubsub_v1/subscriber/test_subscriber_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def test_init_w_api_endpoint(creds):

assert (client._transport.grpc_channel._channel.target()).decode(
"utf-8"
) == "testendpoint.google.com:443"
) == "dns:///testendpoint.google.com:443"


def test_init_w_empty_client_options(creds):
client = subscriber.Client(client_options={}, credentials=creds)

assert (client._transport.grpc_channel._channel.target()).decode(
"utf-8"
) == subscriber_client.SubscriberClient.SERVICE_ADDRESS
) == "dns:///pubsub.googleapis.com:443"


def test_init_client_options_pass_through():
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_init_emulator(monkeypatch):
# Sadly, there seems to be no good way to do this without poking at
# the private API of gRPC.
channel = client._transport.pull._channel
assert channel.target().decode("utf8") == "/baz/bacon:123"
assert channel.target().decode("utf8") == "dns:////baz/bacon:123"


def test_class_method_factory():
Expand Down

0 comments on commit 272e34e

Please sign in to comment.