@@ -133,17 +133,28 @@ def test_init_w_api_endpoint(creds):
133
133
client_options = {"api_endpoint" : "testendpoint.google.com" }
134
134
client = publisher .Client (client_options = client_options , credentials = creds )
135
135
136
+ # Behavior to include dns prefix changed in gRPCv1.63
137
+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
138
+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
139
+ _EXPECTED_TARGET = "dns:///testendpoint.google.com:443"
140
+ else :
141
+ _EXPECTED_TARGET = "testendpoint.google.com:443"
136
142
assert (client ._transport .grpc_channel ._channel .target ()).decode (
137
143
"utf-8"
138
- ) == "testendpoint.google.com:443"
144
+ ) == _EXPECTED_TARGET
139
145
140
146
141
147
def test_init_w_empty_client_options (creds ):
142
148
client = publisher .Client (client_options = {}, credentials = creds )
143
-
149
+ # Behavior to include dns prefix changed in gRPCv1.63
150
+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
151
+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
152
+ _EXPECTED_TARGET = "dns:///pubsub.googleapis.com:443"
153
+ else :
154
+ _EXPECTED_TARGET = "pubsub.googleapis.com:443"
144
155
assert (client ._transport .grpc_channel ._channel .target ()).decode (
145
156
"utf-8"
146
- ) == publisher_client . PublisherClient . SERVICE_ADDRESS
157
+ ) == _EXPECTED_TARGET
147
158
148
159
149
160
def test_init_client_options_pass_through ():
@@ -182,7 +193,13 @@ def test_init_emulator(monkeypatch):
182
193
# Sadly, there seems to be no good way to do this without poking at
183
194
# the private API of gRPC.
184
195
channel = client ._transport .publish ._channel
185
- assert channel .target ().decode ("utf8" ) == "/foo/bar:123"
196
+ # Behavior to include dns prefix changed in gRPCv1.63
197
+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
198
+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
199
+ _EXPECTED_TARGET = "dns:////foo/bar:123"
200
+ else :
201
+ _EXPECTED_TARGET = "/foo/bar:123"
202
+ assert channel .target ().decode ("utf8" ) == _EXPECTED_TARGET
186
203
187
204
188
205
def test_message_ordering_enabled (creds ):
0 commit comments