Skip to content

Commit

Permalink
remove _return_pipeline_response
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed Sep 27, 2021
1 parent d1e84d3 commit c593b0c
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 63 deletions.
3 changes: 0 additions & 3 deletions sdk/core/azure-core/azure/core/_pipeline_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,5 @@ def send_request(self, request, **kwargs):
:rtype: ~azure.core.rest.HttpResponse
"""
stream = kwargs.pop("stream", False) # want to add default value
return_pipeline_response = kwargs.pop("_return_pipeline_response", False)
pipeline_response = self._pipeline.run(request, stream=stream, **kwargs) # pylint: disable=protected-access
if return_pipeline_response:
return pipeline_response
return pipeline_response.http_response
3 changes: 0 additions & 3 deletions sdk/core/azure-core/azure/core/_pipeline_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,9 @@ def _build_pipeline(self, config, **kwargs): # pylint: disable=no-self-use
return AsyncPipeline(transport, policies)

async def _make_pipeline_call(self, request, **kwargs):
return_pipeline_response = kwargs.pop("_return_pipeline_response", False)
pipeline_response = await self._pipeline.run(
request, **kwargs # pylint: disable=protected-access
)
if return_pipeline_response:
return pipeline_response
return pipeline_response.http_response

def send_request(
Expand Down
8 changes: 3 additions & 5 deletions sdk/core/azure-core/azure/core/polling/async_base_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ async def request_status(self, status_link): # pylint:disable=invalid-overridde
# want to keep making azure.core.rest calls
from azure.core.rest import HttpRequest as RestHttpRequest
request = RestHttpRequest("GET", status_link)
return await self._client.send_request(
request, _return_pipeline_response=True, **self._operation_config
)
# if I am a azure.core.pipeline.transport.HttpResponse
request = self._client.get(status_link)
else:
# if I am a azure.core.pipeline.transport.HttpResponse
request = self._client.get(status_link)

# can't use send_request in this case, because send_request is still provisional
return await self._client._pipeline.run( # pylint: disable=protected-access
Expand Down
8 changes: 3 additions & 5 deletions sdk/core/azure-core/azure/core/polling/base_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,9 @@ def request_status(self, status_link):
# want to keep making azure.core.rest calls
from azure.core.rest import HttpRequest as RestHttpRequest
request = RestHttpRequest("GET", status_link)
return self._client.send_request(
request, _return_pipeline_response=True, **self._operation_config
)
# if I am a azure.core.pipeline.transport.HttpResponse
request = self._client.get(status_link)
else:
# if I am a azure.core.pipeline.transport.HttpResponse
request = self._client.get(status_link)

# can't use send_request in this case, because send_request is still provisional
return self._client._pipeline.run( # pylint: disable=protected-access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,6 @@ async def test_multipart_files_content(send_request):
)
await send_request(request)

@pytest.mark.asyncio
async def test_send_request_return_pipeline_response(client):
# we use return_pipeline_response for some cases in autorest
request = HttpRequest("GET", "/basic/string")
response = await client.send_request(request, _return_pipeline_response=True)
assert hasattr(response, "http_request")
assert hasattr(response, "http_response")
assert hasattr(response, "context")
assert response.http_response.text() == "Hello, world!"
assert hasattr(response.http_request, "content")

@pytest.mark.asyncio
async def test_text_and_encoding(send_request):
response = await send_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _callback(response):
@pytest.fixture
def lro_poller(client, deserialization_callback):
async def _callback(request, **kwargs):
initial_response = await client.send_request(
request.url = client._client.format_url(request.url)
initial_response = await client._client._pipeline.run(
request=request,
_return_pipeline_response=True
)
return AsyncLROPoller(
client._client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,6 @@ async def test_iter_read_back_and_forth(client):
with pytest.raises(ResponseNotReadError):
response.text()

@pytest.mark.asyncio
async def test_stream_with_return_pipeline_response(client):
request = HttpRequest("GET", "/basic/string")
pipeline_response = await client.send_request(request, stream=True, _return_pipeline_response=True)
assert hasattr(pipeline_response, "http_request")
assert hasattr(pipeline_response.http_request, "content")
assert hasattr(pipeline_response, "http_response")
assert hasattr(pipeline_response, "context")
parts = []
async for part in pipeline_response.http_response.iter_bytes():
parts.append(part)
assert parts == [b'Hello, world!']
await client.close()

@pytest.mark.asyncio
async def test_error_reading(client):
request = HttpRequest("GET", "/errors/403")
Expand Down
10 changes: 0 additions & 10 deletions sdk/core/azure-core/tests/test_rest_http_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,6 @@ def test_put_xml_basic(send_request):
)
send_request(request)

def test_send_request_return_pipeline_response(client):
# we use return_pipeline_response for some cases in autorest
request = HttpRequest("GET", "/basic/string")
response = client.send_request(request, _return_pipeline_response=True)
assert hasattr(response, "http_request")
assert hasattr(response, "http_response")
assert hasattr(response, "context")
assert response.http_response.text() == "Hello, world!"
assert hasattr(response.http_request, "content")

def test_text_and_encoding(send_request):
response = send_request(
request=HttpRequest("GET", "/encoding/emoji"),
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/azure-core/tests/test_rest_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _callback(response):
@pytest.fixture
def lro_poller(client, deserialization_callback):
def _callback(request, **kwargs):
initial_response = client.send_request(
request.url = client._client.format_url(request.url)
initial_response = client._client._pipeline.run(
request=request,
_return_pipeline_response=True
)
return LROPoller(
client._client,
Expand Down
8 changes: 0 additions & 8 deletions sdk/core/azure-core/tests/test_rest_stream_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,6 @@ def test_iter_read_back_and_forth(client):
with pytest.raises(ResponseNotReadError):
response.text()

def test_stream_with_return_pipeline_response(client):
request = HttpRequest("GET", "/basic/string")
pipeline_response = client.send_request(request, stream=True, _return_pipeline_response=True)
assert hasattr(pipeline_response, "http_request")
assert hasattr(pipeline_response, "http_response")
assert hasattr(pipeline_response, "context")
assert list(pipeline_response.http_response.iter_bytes()) == [b'Hello, world!']

def test_error_reading(client):
request = HttpRequest("GET", "/errors/403")
with client.send_request(request, stream=True) as response:
Expand Down

0 comments on commit c593b0c

Please sign in to comment.