File tree Expand file tree Collapse file tree 2 files changed +29
-15
lines changed
sdk/storage/azure-storage-blob/tests Expand file tree Collapse file tree 2 files changed +29
-15
lines changed Original file line number Diff line number Diff line change 4040 ResourceTypes ,
4141 RetentionPolicy ,
4242 StandardBlobTier ,
43+ StorageErrorCode ,
4344 download_blob_from_url ,
4445 generate_account_sas ,
4546 generate_blob_sas ,
@@ -1676,14 +1677,20 @@ def test_abort_copy_blob(self, **kwargs):
16761677 copy = copied_blob .start_copy_from_url (source_blob )
16771678 assert copy ['copy_status' ] == 'pending'
16781679
1679- copied_blob .abort_copy (copy )
1680- props = self ._wait_for_async_copy (copied_blob )
1681- assert props .copy .status == 'aborted'
1680+ try :
1681+ copied_blob .abort_copy (copy )
1682+ props = self ._wait_for_async_copy (copied_blob )
1683+ assert props .copy .status == 'aborted'
16821684
1683- # Assert
1684- actual_data = copied_blob .download_blob ()
1685- assert actual_data .readall () == b""
1686- assert actual_data .properties .copy .status == 'aborted'
1685+ # Assert
1686+ actual_data = copied_blob .download_blob ()
1687+ assert actual_data .readall () == b""
1688+ assert actual_data .properties .copy .status == 'aborted'
1689+
1690+ # In the Live test pipeline, the copy occasionally finishes before it can be aborted.
1691+ # Catch and assert on error code to prevent this test from failing.
1692+ except HttpResponseError as e :
1693+ assert e .error_code == StorageErrorCode .NO_PENDING_COPY_OPERATION
16871694
16881695 @BlobPreparer ()
16891696 @recorded_by_proxy
Original file line number Diff line number Diff line change 4242 ResourceTypes ,
4343 RetentionPolicy ,
4444 StandardBlobTier ,
45+ StorageErrorCode ,
4546 generate_account_sas ,
4647 generate_container_sas ,
4748 generate_blob_sas )
@@ -1812,15 +1813,21 @@ async def test_abort_copy_blob(self, **kwargs):
18121813 copy = await copied_blob .start_copy_from_url (source_blob )
18131814 assert copy ['copy_status' ] == 'pending'
18141815
1815- await copied_blob .abort_copy (copy )
1816- props = await self ._wait_for_async_copy (copied_blob )
1817- assert props .copy .status == 'aborted'
1816+ try :
1817+ await copied_blob .abort_copy (copy )
1818+ props = await self ._wait_for_async_copy (copied_blob )
1819+ assert props .copy .status == 'aborted'
18181820
1819- # Assert
1820- actual_data = await copied_blob .download_blob ()
1821- bytes_data = await (await copied_blob .download_blob ()).readall ()
1822- assert bytes_data == b""
1823- assert actual_data .properties .copy .status == 'aborted'
1821+ # Assert
1822+ actual_data = await copied_blob .download_blob ()
1823+ bytes_data = await (await copied_blob .download_blob ()).readall ()
1824+ assert bytes_data == b""
1825+ assert actual_data .properties .copy .status == 'aborted'
1826+
1827+ # In the Live test pipeline, the copy occasionally finishes before it can be aborted.
1828+ # Catch and assert on error code to prevent this test from failing.
1829+ except HttpResponseError as e :
1830+ assert e .error_code == StorageErrorCode .NO_PENDING_COPY_OPERATION
18241831
18251832 @BlobPreparer ()
18261833 @recorded_by_proxy_async
You can’t perform that action at this time.
0 commit comments