From 128b89096f36a9acf8dd56dbc1db736874a669d1 Mon Sep 17 00:00:00 2001 From: xiafu Date: Wed, 2 Oct 2019 00:32:39 -0700 Subject: [PATCH] Fix Test and Conflict --- .../tests/test_page_blob.py | 21 ++++++-- .../tests/test_page_blob_async.py | 10 +++- .../azure-storage-file/tests/test_get_file.py | 48 +++++++++---------- .../tests/test_get_file_async.py | 48 +++++++++---------- 4 files changed, 72 insertions(+), 55 deletions(-) diff --git a/sdk/storage/azure-storage-blob/tests/test_page_blob.py b/sdk/storage/azure-storage-blob/tests/test_page_blob.py index b6bbe7585d5f..e7084aff8f7f 100644 --- a/sdk/storage/azure-storage-blob/tests/test_page_blob.py +++ b/sdk/storage/azure-storage-blob/tests/test_page_blob.py @@ -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 @@ -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() diff --git a/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py index 1010940988be..d231f626e369 100644 --- a/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py @@ -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): diff --git a/sdk/storage/azure-storage-file/tests/test_get_file.py b/sdk/storage/azure-storage-file/tests/test_get_file.py index 16a201a1f566..52f0391fe65d 100644 --- a/sdk/storage/azure-storage-file/tests/test_get_file.py +++ b/sdk/storage/azure-storage-file/tests/test_get_file.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) @@ -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): @@ -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, diff --git a/sdk/storage/azure-storage-file/tests/test_get_file_async.py b/sdk/storage/azure-storage-file/tests/test_get_file_async.py index 3ff17a3500cd..644dae4a1afe 100644 --- a/sdk/storage/azure-storage-file/tests/test_get_file_async.py +++ b/sdk/storage/azure-storage-file/tests/test_get_file_async.py @@ -222,7 +222,7 @@ async def _test_get_file_to_bytes_async(self): # Act file_output = await file_client.download_file() - file_content = await file_output.content_as_bytes(max_connections=2) + file_content = await file_output.content_as_bytes(max_concurrency=2) # Assert self.assertEqual(self.byte_data, file_content) @@ -256,7 +256,7 @@ def callback(response): # Act file_output = await file_client.download_file(raw_response_hook=callback) - file_content = await file_output.content_as_bytes(max_connections=2) + file_content = await file_output.content_as_bytes(max_concurrency=2) # Assert self.assertEqual(self.byte_data, file_content) @@ -362,7 +362,7 @@ async def _test_get_file_to_stream_async(self): # Act with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file() - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -430,7 +430,7 @@ def callback(response): # Act with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -469,7 +469,7 @@ def callback(response): # Act with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -511,7 +511,7 @@ def callback(response): # Act with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -558,7 +558,7 @@ async def _test_get_file_to_stream_from_snapshot_async(self): # Act with open(FILE_PATH, 'wb') as stream: props = await snapshot_client.download_file() - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -607,7 +607,7 @@ def callback(response): # Act with open(FILE_PATH, 'wb') as stream: props = await snapshot_client.download_file(raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -657,7 +657,7 @@ def callback(response): # Act with open(FILE_PATH, 'wb') as stream: props = await snapshot_client.download_file(raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -711,7 +711,7 @@ def callback(response): # Act with open(FILE_PATH, 'wb') as stream: props = await snapshot_client.download_file(raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -748,7 +748,7 @@ async def _test_ranged_get_file_to_path_async(self): end_range = self.MAX_SINGLE_GET_SIZE + 1024 with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(offset=1, length=end_range) - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -851,7 +851,7 @@ def callback(response): end_range = self.MAX_SINGLE_GET_SIZE + 1024 with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(offset=start_range, length=end_range, raw_response_hook=callback) - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -883,7 +883,7 @@ async def _test_ranged_get_file_to_path_small_async(self): # Act with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(offset=1, length=4) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -910,7 +910,7 @@ async def _test_ranged_get_file_to_path_non_parallel_async(self): # Act with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(offset=1, length=3) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -946,7 +946,7 @@ async def _test_ranged_get_file_to_path_invalid_range_parallel_async(self): end_range = 2 * self.MAX_SINGLE_GET_SIZE with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(offset=1, length=end_range) - props = await props.download_to_stream(stream, max_connections=2) + props = await props.download_to_stream(stream, max_concurrency=2) # Assert self.assertIsInstance(props, FileProperties) @@ -979,7 +979,7 @@ async def _test_ranged_get_file_to_path_invalid_range_non_parallel_async(self): end_range = 2 * self.MAX_SINGLE_GET_SIZE with open(FILE_PATH, 'wb') as stream: props = await file_client.download_file(offset=1, length=end_range) - props = await props.download_to_stream(stream, max_connections=1) + props = await props.download_to_stream(stream, max_concurrency=1) # Assert self.assertIsInstance(props, FileProperties) @@ -1012,7 +1012,7 @@ async def _test_get_file_to_text_async(self): # Act file_content = await file_client.download_file() - file_content = await file_content.content_as_text(max_connections=2) + file_content = await file_content.content_as_text(max_concurrency=2) # Assert self.assertEqual(text_data, file_content) @@ -1049,7 +1049,7 @@ def callback(response): # Act file_content = await file_client.download_file(raw_response_hook=callback) - file_content = await file_content.content_as_text(max_connections=2) + file_content = await file_content.content_as_text(max_concurrency=2) # Assert self.assertEqual(text_data, file_content) @@ -1087,7 +1087,7 @@ def callback(response): # Act file_content = await file_client.download_file(raw_response_hook=callback) - file_content = await file_content.content_as_text(max_connections=1) + file_content = await file_content.content_as_text(max_concurrency=1) # Assert self.assertEqual(text_data, file_content) @@ -1221,7 +1221,7 @@ async def _test_get_file_non_seekable_async(self): with open(FILE_PATH, 'wb') as stream: non_seekable_stream = StorageGetFileTest.NonSeekableFile(stream) file_props = await file_client.download_file() - file_props = await file_props.download_to_stream(non_seekable_stream, max_connections=1) + file_props = await file_props.download_to_stream(non_seekable_stream, max_concurrency=1) # Assert self.assertIsInstance(file_props, FileProperties) @@ -1255,7 +1255,7 @@ async def _test_get_file_non_seekable_parallel_async(self): with self.assertRaises(ValueError): data = await file_client.download_file() - await data.download_to_stream(non_seekable_stream, max_connections=2) + await data.download_to_stream(non_seekable_stream, max_concurrency=2) # Assert @@ -1290,7 +1290,7 @@ async def _test_get_file_non_seekable_from_snapshot_async(self): with open(FILE_PATH, 'wb') as stream: non_seekable_stream = StorageGetFileTest.NonSeekableFile(stream) file_props = await snapshot_client.download_file() - file_props = await file_props.download_to_stream(non_seekable_stream, max_connections=1) + file_props = await file_props.download_to_stream(non_seekable_stream, max_concurrency=1) # Assert self.assertIsInstance(file_props, FileProperties) @@ -1335,7 +1335,7 @@ async def _test_get_file_non_seekable_parallel_from_snapshot_async(self): with self.assertRaises(ValueError): data = await snapshot_client.download_file() - await data.download_to_stream(non_seekable_stream, max_connections=2) + await data.download_to_stream(non_seekable_stream, max_concurrency=2) @record def test_get_file_non_seekable_parallel_from_snapshot_async(self): @@ -1407,7 +1407,7 @@ def callback(response): # Act file_content = await file_client.download_file(raw_response_hook=callback) - file_bytes = await file_content.content_as_bytes(max_connections=2) + file_bytes = await file_content.content_as_bytes(max_concurrency=2) # Assert self.assertEqual(byte_data, file_bytes)