Skip to content

Commit

Permalink
Fix Test and Conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
xiafu-msft committed Oct 2, 2019
1 parent b9fb1cc commit 128b890
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 55 deletions.
21 changes: 16 additions & 5 deletions sdk/storage/azure-storage-blob/tests/test_page_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,9 +1568,15 @@ def test_download_sparse_page_blob_non_parallel(self):
self.assertEqual(data, content[start: end + 1])
# assert all unlisted ranges are empty
for byte in content[:start-1]:
self.assertEqual(byte, 0)
try:
self.assertEqual(byte, '\x00')
except:
self.assertEqual(byte, 0)
for byte in content[end+1:]:
self.assertEqual(byte, 0)
try:
self.assertEqual(byte, '\x00')
except:
self.assertEqual(byte, 0)

def test_download_sparse_page_blob_parallel(self):
# parallel tests introduce random order of requests, can only run live
Expand Down Expand Up @@ -1598,10 +1604,15 @@ def test_download_sparse_page_blob_parallel(self):
self.assertEqual(data, content[start: end + 1])
# assert all unlisted ranges are empty
for byte in content[:start - 1]:
self.assertEqual(byte, 0)
try:
self.assertEqual(byte, '\x00')
except:
self.assertEqual(byte, 0)
for byte in content[end + 1:]:
self.assertEqual(byte, 0)

try:
self.assertEqual(byte, '\x00')
except:
self.assertEqual(byte, 0)
# ------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
10 changes: 8 additions & 2 deletions sdk/storage/azure-storage-blob/tests/test_page_blob_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,9 +1869,15 @@ async def _test_download_sparse_page_blob(self):
self.assertEqual(data, content[start: end + 1])
# assert all unlisted ranges are empty
for byte in content[:start-1]:
self.assertEqual(byte, 0)
try:
self.assertEqual(byte, '\x00')
except:
self.assertEqual(byte, 0)
for byte in content[end+1:]:
self.assertEqual(byte, 0)
try:
self.assertEqual(byte, '\x00')
except:
self.assertEqual(byte, 0)

@record
def test_download_sparse_page_blob_async(self):
Expand Down
48 changes: 24 additions & 24 deletions sdk/storage/azure-storage-file/tests/test_get_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_get_file_to_bytes(self):
max_chunk_get_size=self.MAX_CHUNK_GET_SIZE)

# Act
file_content = file_client.download_file().content_as_bytes(max_connections=2)
file_content = file_client.download_file().content_as_bytes(max_concurrency=2)

# Assert
self.assertEqual(self.byte_data, file_content)
Expand All @@ -208,7 +208,7 @@ def callback(response):
progress.append((current, total))

# Act
file_content = file_client.download_file(raw_response_hook=callback).content_as_bytes(max_connections=2)
file_content = file_client.download_file(raw_response_hook=callback).content_as_bytes(max_concurrency=2)

# Assert
self.assertEqual(self.byte_data, file_content)
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_get_file_to_stream(self):

# Act
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file().download_to_stream(stream, max_connections=2)
props = file_client.download_file().download_to_stream(stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -350,7 +350,7 @@ def callback(response):
# Act
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(raw_response_hook=callback).download_to_stream(
stream, max_connections=2)
stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -384,7 +384,7 @@ def callback(response):
# Act
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(raw_response_hook=callback).download_to_stream(
stream, max_connections=1)
stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -421,7 +421,7 @@ def callback(response):
# Act
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(raw_response_hook=callback).download_to_stream(
stream, max_connections=1)
stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -461,7 +461,7 @@ def test_get_file_to_stream_from_snapshot(self):

# Act
with open(FILE_PATH, 'wb') as stream:
props = snapshot_client.download_file().download_to_stream(stream, max_connections=2)
props = snapshot_client.download_file().download_to_stream(stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -504,7 +504,7 @@ def callback(response):
# Act
with open(FILE_PATH, 'wb') as stream:
props = snapshot_client.download_file(raw_response_hook=callback).download_to_stream(
stream, max_connections=2)
stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -549,7 +549,7 @@ def callback(response):
# Act
with open(FILE_PATH, 'wb') as stream:
props = snapshot_client.download_file(raw_response_hook=callback).download_to_stream(
stream, max_connections=1)
stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -598,7 +598,7 @@ def callback(response):
# Act
with open(FILE_PATH, 'wb') as stream:
props = snapshot_client.download_file(raw_response_hook=callback).download_to_stream(
stream, max_connections=1)
stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -629,7 +629,7 @@ def test_ranged_get_file_to_path(self):
end_range = self.MAX_SINGLE_GET_SIZE + 1024
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(offset=1, length=end_range).download_to_stream(
stream, max_connections=2)
stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -712,7 +712,7 @@ def callback(response):
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(
offset=start_range, length=end_range, raw_response_hook=callback).download_to_stream(
stream, max_connections=2)
stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand All @@ -739,7 +739,7 @@ def test_ranged_get_file_to_path_small(self):
# Act
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(
offset=1, length=4).download_to_stream(stream, max_connections=1)
offset=1, length=4).download_to_stream(stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand All @@ -761,7 +761,7 @@ def test_ranged_get_file_to_path_non_parallel(self):
# Act
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(
offset=1, length=3).download_to_stream(stream, max_connections=1)
offset=1, length=3).download_to_stream(stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -792,7 +792,7 @@ def test_ranged_get_file_to_path_invalid_range_parallel(self):
end_range = 2 * self.MAX_SINGLE_GET_SIZE
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(
offset=1, length=end_range).download_to_stream(stream, max_connections=2)
offset=1, length=end_range).download_to_stream(stream, max_concurrency=2)

# Assert
self.assertIsInstance(props, FileProperties)
Expand Down Expand Up @@ -820,7 +820,7 @@ def test_ranged_get_file_to_path_invalid_range_non_parallel(self):
end_range = 2 * self.MAX_SINGLE_GET_SIZE
with open(FILE_PATH, 'wb') as stream:
props = file_client.download_file(
offset=1, length=end_range).download_to_stream(stream, max_connections=1)
offset=1, length=end_range).download_to_stream(stream, max_concurrency=1)

# Assert
self.assertIsInstance(props, FileProperties)
Expand All @@ -846,7 +846,7 @@ def test_get_file_to_text(self):
file_client.upload_file(text_data)

# Act
file_content = file_client.download_file().content_as_text(max_connections=2)
file_content = file_client.download_file().content_as_text(max_concurrency=2)

# Assert
self.assertEqual(text_data, file_content)
Expand Down Expand Up @@ -876,7 +876,7 @@ def callback(response):
progress.append((current, total))

# Act
file_content = file_client.download_file(raw_response_hook=callback).content_as_text(max_connections=2)
file_content = file_client.download_file(raw_response_hook=callback).content_as_text(max_concurrency=2)

# Assert
self.assertEqual(text_data, file_content)
Expand Down Expand Up @@ -908,7 +908,7 @@ def callback(response):
progress.append((current, total))

# Act
file_content = file_client.download_file(raw_response_hook=callback).content_as_text(max_connections=1)
file_content = file_client.download_file(raw_response_hook=callback).content_as_text(max_concurrency=1)

# Assert
self.assertEqual(text_data, file_content)
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def test_get_file_non_seekable(self):
with open(FILE_PATH, 'wb') as stream:
non_seekable_stream = StorageGetFileTest.NonSeekableFile(stream)
file_props = file_client.download_file().download_to_stream(
non_seekable_stream, max_connections=1)
non_seekable_stream, max_concurrency=1)

# Assert
self.assertIsInstance(file_props, FileProperties)
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def test_get_file_non_seekable_parallel(self):

with self.assertRaises(ValueError):
file_client.download_file().download_to_stream(
non_seekable_stream, max_connections=2)
non_seekable_stream, max_concurrency=2)

# Assert

Expand Down Expand Up @@ -1077,7 +1077,7 @@ def test_get_file_non_seekable_from_snapshot(self):
with open(FILE_PATH, 'wb') as stream:
non_seekable_stream = StorageGetFileTest.NonSeekableFile(stream)
file_props = snapshot_client.download_file().download_to_stream(
non_seekable_stream, max_connections=1)
non_seekable_stream, max_concurrency=1)

# Assert
self.assertIsInstance(file_props, FileProperties)
Expand Down Expand Up @@ -1116,7 +1116,7 @@ def test_get_file_non_seekable_parallel_from_snapshot(self):

with self.assertRaises(ValueError):
snapshot_client.download_file().download_to_stream(
non_seekable_stream, max_connections=2)
non_seekable_stream, max_concurrency=2)

@record
def test_get_file_exact_get_size(self):
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def callback(response):
file_content = file_client.download_file(raw_response_hook=callback)

# Assert
self.assertEqual(byte_data, file_content.content_as_bytes(max_connections=2))
self.assertEqual(byte_data, file_content.content_as_bytes(max_concurrency=2))
self.assert_download_progress(
len(byte_data),
self.MAX_CHUNK_GET_SIZE,
Expand Down
Loading

0 comments on commit 128b890

Please sign in to comment.