Skip to content

Commit

Permalink
Fix live tests (#7665)
Browse files Browse the repository at this point in the history
* fix live tests

* oops

* few changes
  • Loading branch information
Rakshith Bhyravabhotla authored Oct 8, 2019
1 parent 727e08e commit e617ee2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_container_access_policy(self):
# Use the sas token to authenticate a new client
# [START create_container_client_sastoken]
from azure.storage.blob import ContainerClient
container = ContainerClient(
container = ContainerClient.from_container_url(
container_url="https://account.blob.core.windows.net/mycontainer",
credential=sas_token
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,12 @@ async def _test_get_blob_with_range(self):
content = await stream.content_as_bytes()

# Assert
self.assertEqual(content, self.byte_data[:6])
self.assertEqual(content, self.byte_data[:5])

@record
def test_get_blob_with_range(self):
if TestMode.need_recording_file(self.test_mode):
pytest.skip("Issue with the recording")
loop = asyncio.get_event_loop()
loop.run_until_complete(self._test_get_blob_with_range())

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob/tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def test_set_container_acl_with_three_identifiers(self):
access_policy = AccessPolicy(permission=ContainerSasPermissions(read=True),
expiry=datetime.utcnow() + timedelta(hours=1),
start=datetime.utcnow() - timedelta(minutes=1))
identifiers = {str(i): access_policy for i in range(0, 3)}
identifiers = {i: access_policy for i in range(3)}

# Act
container.set_container_access_policy(identifiers)
Expand Down
4 changes: 3 additions & 1 deletion sdk/storage/azure-storage-blob/tests/test_cpk_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,15 @@ async def _test_put_block_from_url_and_commit(self):
blob = await destination_blob_client.download_blob(cpk=TEST_ENCRYPTION_KEY)

# Assert content was retrieved with the cpk
self.assertEqual(await blob.content_as_bytes(), self.byte_data[0: 8 * 1024 + 1])
self.assertEqual(await blob.content_as_bytes(), self.byte_data[0: 8 * 1024])
self.assertEqual(blob.properties.etag, put_block_list_resp['etag'])
self.assertEqual(blob.properties.last_modified, put_block_list_resp['last_modified'])
self.assertEqual(blob.properties.encryption_key_sha256, TEST_ENCRYPTION_KEY.key_hash)

@record
def test_put_block_from_url_and_commit_async(self):
if TestMode.need_recording_file(self.test_mode):
return
loop = asyncio.get_event_loop()
loop.run_until_complete(self._test_put_block_from_url_and_commit())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ async def _test_get_blob_range_with_overall_md5_async(self):

# Assert
self.assertEqual(b'MDAwMDAwMDA=', content.properties.content_settings.content_md5)
elf.assertEqual(len(downloader), 1024)
self.assertEqual(content.properties.size, 1024)

@record
def test_get_blob_range_with_overall_md5_async(self):
Expand Down
14 changes: 7 additions & 7 deletions sdk/storage/azure-storage-blob/tests/test_page_blob_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,13 @@ async def _test_upload_pages_from_url(self):
destination_blob_client = await self._create_blob(SOURCE_BLOB_SIZE)

# Act: make update page from url calls
resp = await destination_blob_client.upload_pages_from_url(source_blob_client.url + "?" + sas, 0, 4 * 1024,
0)
resp = await destination_blob_client.upload_pages_from_url(
source_blob_client.url + "?" + sas, offset=0, length=4 * 1024, source_offset=0)
self.assertIsNotNone(resp.get('etag'))
self.assertIsNotNone(resp.get('last_modified'))

resp = await destination_blob_client.upload_pages_from_url(source_blob_client.url + "?" + sas, 4 * 1024,
SOURCE_BLOB_SIZE, 4 * 1024)
resp = await destination_blob_client.upload_pages_from_url(source_blob_client.url + "?" + sas, offset=4 * 1024,
length=4 * 1024, source_offset=4 * 1024)
self.assertIsNotNone(resp.get('etag'))
self.assertIsNotNone(resp.get('last_modified'))

Expand Down Expand Up @@ -1024,9 +1024,9 @@ async def _test_get_page_ranges_diff(self):
blob = await self._create_blob(2048)
data = self.get_random_bytes(1536)
snapshot1 = await blob.create_snapshot()
await blob.upload_page(data, 0, 1536)
await blob.upload_page(data, offset=0, length=1536)
snapshot2 = await blob.create_snapshot()
await blob.clear_page(512, 1024)
await blob.clear_page(offset=512, length=512)

# Act
ranges1, cleared1 = await blob.get_page_ranges(previous_snapshot_diff=snapshot1)
Expand Down Expand Up @@ -1617,7 +1617,7 @@ async def _test_incremental_copy_blob(self):
source_blob = await self._create_blob(2048)
data = self.get_random_bytes(512)
resp1 = await source_blob.upload_page(data, offset=0, length=512)
resp2 = await source_blob.upload_page(data, 1024, 1535)
resp2 = await source_blob.upload_page(data, offset=1024, length=512)
source_snapshot_blob = await source_blob.create_snapshot()

snapshot_blob = BlobClient.from_blob_url(
Expand Down

0 comments on commit e617ee2

Please sign in to comment.