Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Some test fixes
  • Loading branch information
annatisch committed Aug 5, 2019
commit ed649efbb6eb7dde2e2ff3a1b4ab737e7121a304
13 changes: 9 additions & 4 deletions sdk/storage/azure-storage-blob/tests/test_blob_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import platform

from azure.storage.blob import (
VERSION,
BlobServiceClient,
ContainerClient,
BlobClient,
Expand Down Expand Up @@ -396,7 +397,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-blob/12.0.0b1 Python/{} ({})".format(
"azsdk-python-storage-blob/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -412,7 +414,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v1.0 azsdk-python-storage-blob/12.0.0b1 Python/{} ({})".format(
"TestApp/v1.0 azsdk-python-storage-blob/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -422,7 +425,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v2.0 azsdk-python-storage-blob/12.0.0b1 Python/{} ({})".format(
"TestApp/v2.0 azsdk-python-storage-blob/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -436,7 +440,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-blob/12.0.0b1 Python/{} ({}) customer_user_agent".format(
"azsdk-python-storage-blob/{} Python/{} ({}) customer_user_agent".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand Down
13 changes: 9 additions & 4 deletions sdk/storage/azure-storage-blob/tests/test_blob_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import platform
import asyncio

from azure.storage.blob import VERSION
from azure.storage.blob.aio import (
BlobServiceClient,
ContainerClient,
Expand Down Expand Up @@ -418,7 +419,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-blob/12.0.0b1 Python/{} ({})".format(
"azsdk-python-storage-blob/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -438,7 +440,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v1.0 azsdk-python-storage-blob/12.0.0b1 Python/{} ({})".format(
"TestApp/v1.0 azsdk-python-storage-blob/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -448,7 +451,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v2.0 azsdk-python-storage-blob/12.0.0b1 Python/{} ({})".format(
"TestApp/v2.0 azsdk-python-storage-blob/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -466,7 +470,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-blob/12.0.0b1 Python/{} ({}) customer_user_agent".format(
"azsdk-python-storage-blob/{} Python/{} ({}) customer_user_agent".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file/tests/test_file_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def setUp(self):
self.fsc2 = FileServiceClient(remote_url, credential=remote_credential, transport=AiohttpTestTransport())
self.remote_share_name = None
loop = asyncio.get_event_loop()
loop.run_until_complete(self.fsc.__aenter__())
loop.run_until_complete(self.fsc2.__aenter__())

def tearDown(self):
if not self.is_playback():
Expand Down
29 changes: 17 additions & 12 deletions sdk/storage/azure-storage-file/tests/test_file_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import platform

from azure.storage.file import (
VERSION,
FileServiceClient,
ShareClient,
DirectoryClient,
Expand Down Expand Up @@ -134,7 +135,7 @@ def test_create_service_missing_arguments(self):
for service_type in SERVICES:
# Act
with self.assertRaises(ValueError):
service = service_type(None)
service_type(None)

def test_create_service_with_socket_timeout(self):
# Arrange
Expand Down Expand Up @@ -204,11 +205,11 @@ def test_create_service_with_connection_string_endpoint_protocol(self):
def test_create_service_with_connection_string_emulated(self):
# Arrange
for service_type in SERVICES.items():
conn_string = 'UseDevelopmentStorage=true;'.format(self.account_name, self.account_key)
conn_string = 'UseDevelopmentStorage=true;'

# Act
with self.assertRaises(ValueError):
service = service_type[0].from_connection_string(
service_type[0].from_connection_string(
conn_string, share='foo', directory_path='bar', file_path='baz')

def test_create_service_with_connection_string_fails_if_secondary_without_primary(self):
Expand All @@ -221,7 +222,7 @@ def test_create_service_with_connection_string_fails_if_secondary_without_primar

# Fails if primary excluded
with self.assertRaises(ValueError):
service = service_type[0].from_connection_string(
service_type[0].from_connection_string(
conn_string, share='foo', directory_path='bar', file_path='baz')

def test_create_service_with_connection_string_succeeds_if_secondary_with_primary(self):
Expand Down Expand Up @@ -251,7 +252,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-file/12.0.0b1 Python/{} ({})".format(
"azsdk-python-storage-file/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -263,25 +265,27 @@ def test_user_agent_custom(self):
service = FileServiceClient(
self.get_file_url(), credential=self.account_key, user_agent=custom_app)

def callback(response):
def callback1(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v1.0 azsdk-python-storage-file/12.0.0b1 Python/{} ({})".format(
"TestApp/v1.0 azsdk-python-storage-file/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

service.get_service_properties(raw_response_hook=callback)
service.get_service_properties(raw_response_hook=callback1)

def callback(response):
def callback2(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v2.0 azsdk-python-storage-file/12.0.0b1 Python/{} ({})".format(
"TestApp/v2.0 azsdk-python-storage-file/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

service.get_service_properties(raw_response_hook=callback, user_agent="TestApp/v2.0")
service.get_service_properties(raw_response_hook=callback2, user_agent="TestApp/v2.0")

@record
def test_user_agent_append(self):
Expand All @@ -291,7 +295,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-file/12.0.0b1 Python/{} ({}) customer_user_agent".format(
"azsdk-python-storage-file/{} Python/{} ({}) customer_user_agent".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand Down
29 changes: 17 additions & 12 deletions sdk/storage/azure-storage-file/tests/test_file_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import asyncio
from azure.core.pipeline.transport import AioHttpTransport
from multidict import CIMultiDict, CIMultiDictProxy
from azure.storage.file import VERSION
from azure.storage.file.aio import (
FileServiceClient,
ShareClient,
Expand Down Expand Up @@ -154,7 +155,7 @@ def test_create_service_missing_arguments_async(self):
for service_type in SERVICES:
# Act
with self.assertRaises(ValueError):
service = service_type(None)
service_type(None)

@record
def test_create_service_with_socket_timeout_async(self):
Expand Down Expand Up @@ -229,11 +230,11 @@ def test_create_service_with_connection_string_endpoint_protocol_async(self):
def test_create_service_with_connection_string_emulated_async(self):
# Arrange
for service_type in SERVICES.items():
conn_string = 'UseDevelopmentStorage=true;'.format(self.account_name, self.account_key)
conn_string = 'UseDevelopmentStorage=true;'

# Act
with self.assertRaises(ValueError):
service = service_type[0].from_connection_string(
service_type[0].from_connection_string(
conn_string, share='foo', directory_path='bar', file_path='baz', transport=AiohttpTestTransport())

@record
Expand All @@ -247,7 +248,7 @@ def test_create_service_with_connection_string_fails_if_secondary_without_primar

# Fails if primary excluded
with self.assertRaises(ValueError):
service = service_type[0].from_connection_string(
service_type[0].from_connection_string(
conn_string, share='foo', directory_path='bar', file_path='baz')

@record
Expand Down Expand Up @@ -277,7 +278,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-file/12.0.0b1 Python/{} ({})".format(
"azsdk-python-storage-file/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -293,25 +295,27 @@ async def _test_user_agent_custom_async(self):
service = FileServiceClient(
self.get_file_url(), credential=self.account_key, user_agent=custom_app, transport=AiohttpTestTransport())

def callback(response):
def callback1(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v1.0 azsdk-python-storage-file/12.0.0b1 Python/{} ({})".format(
"TestApp/v1.0 azsdk-python-storage-file/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

await service.get_service_properties(raw_response_hook=callback)
await service.get_service_properties(raw_response_hook=callback1)

def callback(response):
def callback2(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v2.0 azsdk-python-storage-file/12.0.0b1 Python/{} ({})".format(
"TestApp/v2.0 azsdk-python-storage-file/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

await service.get_service_properties(raw_response_hook=callback, user_agent="TestApp/v2.0")
await service.get_service_properties(raw_response_hook=callback2, user_agent="TestApp/v2.0")

@record
def test_user_agent_custom_async(self):
Expand All @@ -325,7 +329,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-file/12.0.0b1 Python/{} ({}) customer_user_agent".format(
"azsdk-python-storage-file/{} Python/{} ({}) customer_user_agent".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand Down
13 changes: 9 additions & 4 deletions sdk/storage/azure-storage-queue/tests/test_queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import platform

from azure.storage.queue import (
VERSION,
QueueServiceClient,
QueueClient,
)
Expand Down Expand Up @@ -352,7 +353,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-queue/12.0.0b1 Python/{} ({})".format(
"azsdk-python-storage-queue/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -368,7 +370,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v1.0 azsdk-python-storage-queue/12.0.0b1 Python/{} ({})".format(
"TestApp/v1.0 azsdk-python-storage-queue/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -378,7 +381,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v2.0 azsdk-python-storage-queue/12.0.0b1 Python/{} ({})".format(
"TestApp/v2.0 azsdk-python-storage-queue/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -392,7 +396,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-queue/12.0.0b1 Python/{} ({}) customer_user_agent".format(
"azsdk-python-storage-queue/{} Python/{} ({}) customer_user_agent".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand Down
13 changes: 9 additions & 4 deletions sdk/storage/azure-storage-queue/tests/test_queue_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import asyncio
from azure.core.pipeline.transport import AioHttpTransport
from multidict import CIMultiDict, CIMultiDictProxy
from azure.storage.queue import VERSION
from azure.storage.queue.aio import (
QueueServiceClient,
QueueClient
Expand Down Expand Up @@ -374,7 +375,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-queue/12.0.0b1 Python/{} ({})".format(
"azsdk-python-storage-queue/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -394,7 +396,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v1.0 azsdk-python-storage-queue/12.0.0b1 Python/{} ({})".format(
"TestApp/v1.0 azsdk-python-storage-queue/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -404,7 +407,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"TestApp/v2.0 azsdk-python-storage-queue/12.0.0b1 Python/{} ({})".format(
"TestApp/v2.0 azsdk-python-storage-queue/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand All @@ -422,7 +426,8 @@ def callback(response):
self.assertTrue('User-Agent' in response.http_request.headers)
self.assertEqual(
response.http_request.headers['User-Agent'],
"azsdk-python-storage-queue/12.0.0b1 Python/{} ({}) customer_user_agent".format(
"azsdk-python-storage-queue/{} Python/{} ({}) customer_user_agent".format(
VERSION,
platform.python_version(),
platform.platform()))

Expand Down