Skip to content

Commit 5cddf4f

Browse files
committed
consolidate some options tests
Signed-off-by: Filinto Duran <1373693+filintod@users.noreply.github.com>
1 parent 7980fd8 commit 5cddf4f

File tree

4 files changed

+40
-175
lines changed

4 files changed

+40
-175
lines changed

tests/durabletask/test_client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,23 @@ def test_grpc_channel_with_host_name_protocol_stripping():
120120
args, kwargs = mock_secure_channel.call_args
121121
assert args[0] == host_name
122122
assert "options" in kwargs and kwargs["options"] is None
123+
124+
125+
def test_sync_channel_passes_base_options_and_max_lengths():
126+
base_options = [
127+
("grpc.max_send_message_length", 1234),
128+
("grpc.max_receive_message_length", 5678),
129+
("grpc.primary_user_agent", "durabletask-tests"),
130+
]
131+
with patch("grpc.insecure_channel") as mock_channel:
132+
get_grpc_channel(HOST_ADDRESS, False, options=base_options)
133+
# Ensure called with options kwarg
134+
assert mock_channel.call_count == 1
135+
args, kwargs = mock_channel.call_args
136+
assert args[0] == HOST_ADDRESS
137+
assert "options" in kwargs
138+
opts = kwargs["options"]
139+
# Check our base options made it through
140+
assert ("grpc.max_send_message_length", 1234) in opts
141+
assert ("grpc.max_receive_message_length", 5678) in opts
142+
assert ("grpc.primary_user_agent", "durabletask-tests") in opts

tests/durabletask/test_client_async.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,23 @@ def test_async_client_construct_with_metadata():
149149
interceptors = kwargs["interceptors"]
150150
assert isinstance(interceptors[0], DefaultClientInterceptorImpl)
151151
assert interceptors[0]._metadata == METADATA
152+
153+
154+
def test_aio_channel_passes_base_options_and_max_lengths():
155+
base_options = [
156+
("grpc.max_send_message_length", 4321),
157+
("grpc.max_receive_message_length", 8765),
158+
("grpc.primary_user_agent", "durabletask-aio-tests"),
159+
]
160+
with patch("durabletask.aio.internal.shared.grpc_aio.insecure_channel") as mock_channel:
161+
get_grpc_aio_channel(HOST_ADDRESS, False, options=base_options)
162+
# Ensure called with options kwarg
163+
assert mock_channel.call_count == 1
164+
args, kwargs = mock_channel.call_args
165+
assert args[0] == HOST_ADDRESS
166+
assert "options" in kwargs
167+
opts = kwargs["options"]
168+
# Check our base options made it through
169+
assert ("grpc.max_send_message_length", 4321) in opts
170+
assert ("grpc.max_receive_message_length", 8765) in opts
171+
assert ("grpc.primary_user_agent", "durabletask-aio-tests") in opts

tests/durabletask/test_grpc_aio_channel_options.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

tests/durabletask/test_grpc_channel_options.py

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)