Skip to content

Commit

Permalink
Issue Azure#9324 by DaisyCisneros (Azure#21824)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaisyCisneros authored and rakshith91 committed Apr 10, 2022
1 parent 3eda7f4 commit 7c58820
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions sdk/core/azure-core/tests/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#
# --------------------------------------------------------------------------
import pytest
from azure.core.pipeline.transport import RequestsTransport
from azure.core import PipelineClient
from azure.core.exceptions import DecodeError
from azure.core.pipeline.transport import RequestsTransport
Expand All @@ -44,6 +45,20 @@ def test_decompress_plain_no_header(http_request):
decoded = content.decode('utf-8')
assert decoded == "test"

@pytest.mark.parametrize("http_request", HTTP_REQUESTS)
def test_compress_plain_no_header_offline(port, http_request):
# thanks to Daisy Cisneros for this test!
# expect plain text
request = http_request(method="GET", url="http://localhost:{}/streams/string".format(port))
with RequestsTransport() as sender:
response = sender.send(request, stream=True)
response.raise_for_status()
data = response.stream_download(sender, decompress=False)
content = b"".join(list(data))
decoded = content.decode('utf-8')
assert decoded == "test"

@pytest.mark.live_test_only
@pytest.mark.parametrize("http_request", HTTP_REQUESTS)
def test_compress_plain_no_header(http_request):
# expect plain text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def stream_json_error():
yield '{"error": {"code": "BadRequest", '
yield' "message": "You made a bad request"}}'

def streaming_test():
yield b"test"

def stream_compressed_header_error():
yield b'test'

Expand All @@ -40,7 +43,13 @@ def iterable():
def error():
return Response(stream_json_error(), status=400)

@streams_api.route('/string', methods=['GET'])
def string():
return Response(
streaming_test(), status=200, mimetype="text/plain"
)

@streams_api.route('/compressed', methods=['GET'])
def compressed():
return Response(stream_compressed_header_error(), status=300, headers={"Content-Encoding": "gzip"})


0 comments on commit 7c58820

Please sign in to comment.