Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 _shared.asynctestcase 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