Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/storage/azure-storage-blob",
"Tag": "python/storage/azure-storage-blob_7a600f1c92"
"Tag": "python/storage/azure-storage-blob_9a1e716fe7"
}
7 changes: 4 additions & 3 deletions sdk/storage/azure-storage-blob/tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def verify_blobs(self, blobs_list: list[BlobProperties], blob_names: list[str]):
assert blob.etag is not None
assert blob.last_modified is not None and blob.last_modified.tzinfo is not None
assert blob.creation_time is not None and blob.creation_time.tzinfo is not None
assert blob.last_accessed_on is not None and blob.last_accessed_on.tzinfo is not None
assert blob.last_accessed_on is None or blob.last_accessed_on.tzinfo is not None
assert blob.server_encrypted is True
assert blob.blob_tier is not None
assert blob.blob_tier_inferred is not None
Expand Down Expand Up @@ -325,9 +325,10 @@ def test_arrow_list_blobs_include_versions(self, **kwargs):
container = self.bsc.get_container_client(self.container_name)
blobs_list = list(container.list_blobs(response_format="arrow", include=["versions"]))

assert len(blobs_list) == 1
assert not blobs_list[0].is_current_version
assert len(blobs_list) == 2
assert blobs_list[0].version_id == create_resp["version_id"]
assert not blobs_list[0].is_current_version
assert blobs_list[-1].is_current_version

@BlobPreparer()
@recorded_by_proxy
Expand Down
7 changes: 4 additions & 3 deletions sdk/storage/azure-storage-blob/tests/test_arrow_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def verify_blobs(self, blobs_list: list[BlobProperties], blob_names: list[str]):
assert blob.etag is not None
assert blob.last_modified is not None and blob.last_modified.tzinfo is not None
assert blob.creation_time is not None and blob.creation_time.tzinfo is not None
assert blob.last_accessed_on is not None and blob.last_accessed_on.tzinfo is not None
assert blob.last_accessed_on is None or blob.last_accessed_on.tzinfo is not None
assert blob.server_encrypted is True
assert blob.blob_tier is not None
assert blob.blob_tier_inferred is not None
Expand Down Expand Up @@ -329,9 +329,10 @@ async def test_arrow_list_blobs_include_versions(self, **kwargs):
container = self.bsc.get_container_client(self.container_name)
blobs_list = [blob async for blob in container.list_blobs(response_format="arrow", include=["versions"])]

assert len(blobs_list) == 1
assert not blobs_list[0].is_current_version
assert len(blobs_list) == 2
assert blobs_list[0].version_id == create_resp["version_id"]
assert not blobs_list[0].is_current_version
assert blobs_list[-1].is_current_version

@BlobPreparer()
@recorded_by_proxy_async
Expand Down
16 changes: 11 additions & 5 deletions sdk/storage/azure-storage-blob/tests/test_blob_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from devtools_testutils.storage import StorageRecordedTestCase
from encryption_test_helper import KeyResolver, KeyWrapper, mock_urandom, RSAKeyWrapper
from settings.testcase import BlobPreparer
from test_helpers import _deterministic_urandom

from azure.core.exceptions import HttpResponseError, ResourceExistsError
from azure.storage.blob import BlobServiceClient, BlobType
Expand Down Expand Up @@ -320,7 +321,8 @@ def test_put_blob_chunking_required_mult_of_block_size(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
blob.upload_blob(content, max_concurrency=3)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content, max_concurrency=3)
blob_content = blob.download_blob(max_concurrency=3).readall()

# Assert
Expand All @@ -341,7 +343,8 @@ def test_put_blob_chunking_required_non_mult_of_block_size(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
blob.upload_blob(content, max_concurrency=3)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content, max_concurrency=3)
blob_content = blob.download_blob(max_concurrency=3).readall()

# Assert
Expand All @@ -362,7 +365,8 @@ def test_put_blob_chunking_required_range_specified(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
blob.upload_blob(content, length=self.config.max_single_put_size + 53, max_concurrency=3)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content, length=self.config.max_single_put_size + 53, max_concurrency=3)
blob_content = blob.download_blob(max_concurrency=3).readall()

# Assert
Expand Down Expand Up @@ -405,7 +409,8 @@ def test_put_blob_range(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
blob.upload_blob(content[2:], length=self.config.max_single_put_size + 5, max_concurrency=1)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content[2:], length=self.config.max_single_put_size + 5, max_concurrency=1)
blob_content = blob.download_blob().readall()

# Assert
Expand Down Expand Up @@ -445,7 +450,8 @@ def test_put_blob_serial_upload_chunking(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
blob.upload_blob(content, max_concurrency=1)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content, max_concurrency=1)
blob_content = blob.download_blob().readall()

# Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from devtools_testutils.storage.aio import AsyncStorageRecordedTestCase
from encryption_test_helper import KeyResolver, KeyWrapper, mock_urandom, RSAKeyWrapper
from settings.testcase import BlobPreparer
from test_helpers import _deterministic_urandom

from azure.core.exceptions import HttpResponseError, ResourceExistsError
from azure.storage.blob import BlobType
Expand Down Expand Up @@ -327,7 +328,8 @@ async def test_put_blob_chunking_required_mult_of_block_size(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
await blob.upload_blob(content, max_concurrency=3)
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content, max_concurrency=3)
blob_content = await (await blob.download_blob(max_concurrency=3)).readall()

# Assert
Expand All @@ -348,7 +350,8 @@ async def test_put_blob_chunking_required_non_mult_of_block_size(self, **kwargs)
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
await blob.upload_blob(content, max_concurrency=3)
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content, max_concurrency=3)
blob_content = await (await blob.download_blob(max_concurrency=3)).readall()

# Assert
Expand All @@ -369,7 +372,8 @@ async def test_put_blob_chunking_required_range_specified(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
await blob.upload_blob(content, length=self.config.max_single_put_size + 53, max_concurrency=3)
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content, length=self.config.max_single_put_size + 53, max_concurrency=3)
blob_content = await (await blob.download_blob(max_concurrency=3)).readall()

# Assert
Expand Down Expand Up @@ -412,7 +416,8 @@ async def test_put_blob_range(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
await blob.upload_blob(content[2:], length=self.config.max_single_put_size + 5, max_concurrency=1)
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content[2:], length=self.config.max_single_put_size + 5, max_concurrency=1)
blob_content = await (await blob.download_blob()).readall()

# Assert
Expand Down Expand Up @@ -452,7 +457,8 @@ async def test_put_blob_serial_upload_chunking(self, **kwargs):
blob = self.bsc.get_blob_client(self.container_name, blob_name)

# Act
await blob.upload_blob(content, max_concurrency=1)
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content, max_concurrency=1)
blob_content = await (await blob.download_blob()).readall()

# Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from devtools_testutils.storage import StorageRecordedTestCase
from encryption_test_helper import KeyResolver, KeyWrapper, mock_urandom, RSAKeyWrapper
from settings.testcase import BlobPreparer
from test_helpers import _deterministic_urandom

from azure.core import MatchConditions
from azure.core.exceptions import HttpResponseError, ResourceExistsError
Expand Down Expand Up @@ -127,7 +128,6 @@ def test_validate_encryption(self, **kwargs):

@BlobPreparer()
@recorded_by_proxy
@mock.patch("os.urandom", mock_urandom)
def test_validate_encryption_chunked_upload(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")
storage_account_key = kwargs.pop("storage_account_key")
Expand All @@ -148,7 +148,8 @@ def test_validate_encryption_chunked_upload(self, **kwargs):
content = b"a" * 5 * 1024

# Act
blob.upload_blob(content, overwrite=True)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content, overwrite=True)

blob.require_encryption = False
blob.key_encryption_key = None
Expand Down Expand Up @@ -473,7 +474,6 @@ def test_put_blob_empty(self, **kwargs):

@BlobPreparer()
@recorded_by_proxy
@mock.patch("os.urandom", mock_urandom)
def test_put_blob_single_region_chunked(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")
storage_account_key = kwargs.pop("storage_account_key")
Expand All @@ -494,7 +494,8 @@ def test_put_blob_single_region_chunked(self, **kwargs):
content = b"abcde" * 1024

# Act
blob.upload_blob(content, overwrite=True)
with mock.patch("os.urandom", _deterministic_urandom()):
blob.upload_blob(content, overwrite=True)
data = blob.download_blob().readall()

# Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from devtools_testutils.storage.aio import AsyncStorageRecordedTestCase
from encryption_test_helper import KeyResolver, KeyWrapper, mock_urandom, RSAKeyWrapper
from settings.testcase import BlobPreparer
from test_helpers import _deterministic_urandom
from test_helpers_async import AsyncStream

from azure.core import MatchConditions
Expand Down Expand Up @@ -150,7 +151,7 @@ async def test_validate_encryption_chunked_upload(self, **kwargs):
content = b"a" * 5 * 1024

# Act
with mock.patch("os.urandom", mock_urandom):
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content, overwrite=True)

blob.require_encryption = False
Expand Down Expand Up @@ -498,7 +499,7 @@ async def test_put_blob_single_region_chunked(self, **kwargs):
content = b"abcde" * 1024

# Act
with mock.patch("os.urandom", mock_urandom):
with mock.patch("os.urandom", _deterministic_urandom()):
await blob.upload_blob(content, overwrite=True)
data = await (await blob.download_blob()).readall()

Expand Down
34 changes: 24 additions & 10 deletions sdk/storage/azure-storage-file-share/tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2770,12 +2770,19 @@ def test_abort_copy_file(self, **kwargs):
)
copy_resp = file_client.start_copy_from_url(source_url)
assert copy_resp["copy_status"] == "pending"
file_client.abort_copy(copy_resp)

# Assert
target_file = file_client.download_file()
assert target_file.readall() == b""
assert target_file.properties.copy.status == "aborted"
try:
file_client.abort_copy(copy_resp)

# Assert
target_file = file_client.download_file()
assert target_file.readall() == b""
assert target_file.properties.copy.status == "aborted"

# In the live test pipeline, the copy occasionally finishes before it can be aborted.
# Catch and assert on error code to prevent this test from failing.
except HttpResponseError as e:
assert e.error_code == StorageErrorCode.NO_PENDING_COPY_OPERATION

@pytest.mark.live_test_only
@FileSharePreparer()
Expand Down Expand Up @@ -2817,12 +2824,19 @@ def test_abort_copy_file_with_oauth(self, **kwargs):
)
copy_resp = file_client.start_copy_from_url(source_url)
assert copy_resp["copy_status"] == "pending"
file_client.abort_copy(copy_resp)

# Assert
target_file = file_client.download_file()
assert target_file.readall() == b""
assert target_file.properties.copy.status == "aborted"
try:
file_client.abort_copy(copy_resp)

# Assert
target_file = file_client.download_file()
assert target_file.readall() == b""
assert target_file.properties.copy.status == "aborted"

# In the live test pipeline, the copy occasionally finishes before it can be aborted.
# Catch and assert on error code to prevent this test from failing.
except HttpResponseError as e:
assert e.error_code == StorageErrorCode.NO_PENDING_COPY_OPERATION

@FileSharePreparer()
@recorded_by_proxy
Expand Down
38 changes: 26 additions & 12 deletions sdk/storage/azure-storage-file-share/tests/test_file_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2828,13 +2828,20 @@ async def test_abort_copy_file_async(self, **kwargs):
)
copy_resp = await file_client.start_copy_from_url(source_url)
assert copy_resp["copy_status"] == "pending"
await file_client.abort_copy(copy_resp)

# Assert
target_file = await file_client.download_file()
content = await target_file.readall()
assert content == b""
assert target_file.properties.copy.status == "aborted"
try:
await file_client.abort_copy(copy_resp)

# Assert
target_file = await file_client.download_file()
content = await target_file.readall()
assert content == b""
assert target_file.properties.copy.status == "aborted"

# In the live test pipeline, the copy occasionally finishes before it can be aborted.
# Catch and assert on error code to prevent this test from failing.
except HttpResponseError as e:
assert e.error_code == StorageErrorCode.NO_PENDING_COPY_OPERATION

@pytest.mark.live_test_only
@FileSharePreparer()
Expand Down Expand Up @@ -2877,13 +2884,20 @@ async def test_abort_copy_file_async_with_oauth(self, **kwargs):
)
copy_resp = await file_client.start_copy_from_url(source_url)
assert copy_resp["copy_status"] == "pending"
await file_client.abort_copy(copy_resp)

# Assert
target_file = await file_client.download_file()
content = await target_file.readall()
assert content == b""
assert target_file.properties.copy.status == "aborted"
try:
await file_client.abort_copy(copy_resp)

# Assert
target_file = await file_client.download_file()
content = await target_file.readall()
assert content == b""
assert target_file.properties.copy.status == "aborted"

# In the live test pipeline, the copy occasionally finishes before it can be aborted.
# Catch and assert on error code to prevent this test from failing.
except HttpResponseError as e:
assert e.error_code == StorageErrorCode.NO_PENDING_COPY_OPERATION

@FileSharePreparer()
@recorded_by_proxy_async
Expand Down
Loading