Skip to content

Commit

Permalink
Clean async tests transport (Azure#16973)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasherif-msft authored and rakshith91 committed Jul 16, 2021
1 parent d474b11 commit f66cc0d
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions sdk/storage/azure-storage-blob/tests/test_blob_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
ContainerClient,
BlobClient,
)
from devtools_testutils import ResourceGroupPreparer, StorageAccountPreparer
from azure.core.pipeline.transport import AioHttpTransport
from multidict import CIMultiDict, CIMultiDictProxy
from _shared.testcase import GlobalStorageAccountPreparer
from devtools_testutils.storage.aio import AsyncStorageTestCase

Expand All @@ -33,17 +30,6 @@
_CONNECTION_ENDPOINTS_SECONDARY = {'blob': 'BlobSecondaryEndpoint'}


class AiohttpTestTransport(AioHttpTransport):
"""Workaround to vcrpy bug: https://github.com/kevin1024/vcrpy/pull/461
"""
async def send(self, request, **config):
response = await super(AiohttpTestTransport, self).send(request, **config)
if not isinstance(response.headers, CIMultiDictProxy):
response.headers = CIMultiDictProxy(CIMultiDict(response.internal_response.headers))
response.content_type = response.headers.get("content-type")
return response


class StorageClientTestAsync(AsyncStorageTestCase):
def setUp(self):
super(StorageClientTestAsync, self).setUp()
Expand Down Expand Up @@ -494,7 +480,7 @@ def test_create_blob_client_with_sub_directory_path_in_blob_name(self):
@AsyncStorageTestCase.await_prepared_test
async def test_request_callback_signed_header_async(self, resource_group, location, storage_account, storage_account_key):
# Arrange
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport())
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key)
name = self.get_resource_name('cont')

# Act
Expand All @@ -514,7 +500,7 @@ def callback(request):
@AsyncStorageTestCase.await_prepared_test
async def test_response_callback_async(self, resource_group, location, storage_account, storage_account_key):
# Arrange
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport())
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key)
name = self.get_resource_name('cont')
container = service.get_container_client(name)

Expand All @@ -530,7 +516,7 @@ def callback(response):
@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
async def test_user_agent_default_async(self, resource_group, location, storage_account, storage_account_key):
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport())
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key)

def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
Expand All @@ -543,7 +529,7 @@ def callback(response):
async def test_user_agent_custom_async(self, resource_group, location, storage_account, storage_account_key):
custom_app = "TestApp/v1.0"
service = BlobServiceClient(
self.account_url(storage_account, "blob"), credential=storage_account_key, user_agent=custom_app, transport=AiohttpTestTransport())
self.account_url(storage_account, "blob"), credential=storage_account_key, user_agent=custom_app)

def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
Expand All @@ -566,7 +552,7 @@ def callback(response):
@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
async def test_user_agent_append_async(self, resource_group, location, storage_account, storage_account_key):
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key, transport=AiohttpTestTransport())
service = BlobServiceClient(self.account_url(storage_account, "blob"), credential=storage_account_key)

def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
Expand Down

0 comments on commit f66cc0d

Please sign in to comment.