Skip to content

Commit 16dfd4f

Browse files
Add tests for server streaming methods #280 (#281)
1 parent d5df42c commit 16dfd4f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

packages/gapic-generator/tests/system/test_grpc_streams.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
from google import showcase
1616

1717

18+
metadata = (("showcase-trailer", "hello world"),)
19+
20+
1821
def test_unary_stream(echo):
1922
content = 'The hail in Wales falls mainly on the snails.'
2023
responses = echo.expand({
2124
'content': content,
22-
})
25+
}, metadata=metadata)
2326

2427
# Consume the response and ensure it matches what we expect.
2528
# with pytest.raises(exceptions.NotFound) as exc:
2629
for ground_truth, response in zip(content.split(' '), responses):
2730
assert response.content == ground_truth
2831
assert ground_truth == 'snails.'
2932

30-
# TODO. Check responses.trailing_metadata() content once gapic-showcase
31-
# server returns non-empty trailing metadata.
32-
assert len(responses.trailing_metadata()) == 0
33+
assert responses.trailing_metadata() == metadata
3334

3435

3536
def test_stream_unary(echo):
@@ -50,27 +51,23 @@ def test_stream_stream(echo):
5051
requests = []
5152
requests.append(showcase.EchoRequest(content="hello"))
5253
requests.append(showcase.EchoRequest(content="world!"))
53-
responses = echo.chat(iter(requests))
54+
responses = echo.chat(iter(requests), metadata=metadata)
5455

5556
contents = []
5657
for response in responses:
5758
contents.append(response.content)
5859
assert contents == ['hello', 'world!']
5960

60-
# TODO. Check responses.trailing_metadata() content once gapic-showcase
61-
# server returns non-empty trailing metadata.
62-
assert len(responses.trailing_metadata()) == 0
61+
assert responses.trailing_metadata() == metadata
6362

6463

6564
def test_stream_stream_passing_dict(echo):
6665
requests = [{'content': 'hello'}, {'content': 'world!'}]
67-
responses = echo.chat(iter(requests))
66+
responses = echo.chat(iter(requests), metadata=metadata)
6867

6968
contents = []
7069
for response in responses:
7170
contents.append(response.content)
7271
assert contents == ['hello', 'world!']
7372

74-
# TODO. Check responses.trailing_metadata() content once gapic-showcase
75-
# server returns non-empty trailing metadata.
76-
assert len(responses.trailing_metadata()) == 0
73+
assert responses.trailing_metadata() == metadata

0 commit comments

Comments
 (0)