@@ -31,6 +31,8 @@ class TEST_CONSTANTS:
3131 FILE_STORAGE_GCS = "FILE_STORAGE_GCS"
3232 FILE_STORAGE_MINIO = "FILE_STORAGE_MINIO"
3333 FILE_STORAGE_LOCAL = "FILE_STORAGE_LOCAL"
34+ FILE_STORAGE_S3 = "FILE_STORAGE_S3"
35+ FILE_STORAGE_AZURE = "FILE_STORAGE_AZURE"
3436
3537
3638def file_storage (provider : FileStorageProvider ):
@@ -41,6 +43,10 @@ def file_storage(provider: FileStorageProvider):
4143 creds = json .loads (os .environ .get (TEST_CONSTANTS .FILE_STORAGE_MINIO , "{}" ))
4244 elif provider == FileStorageProvider .LOCAL :
4345 creds = json .loads (os .environ .get (TEST_CONSTANTS .FILE_STORAGE_LOCAL , "{}" ))
46+ elif provider == FileStorageProvider .S3 :
47+ creds = json .loads (os .environ .get (TEST_CONSTANTS .FILE_STORAGE_S3 , "{}" ))
48+ elif provider == FileStorageProvider .AZURE :
49+ creds = json .loads (os .environ .get (TEST_CONSTANTS .FILE_STORAGE_AZURE , "{}" ))
4450 except JSONDecodeError :
4551 creds = {}
4652 file_storage = FileStorage (provider , ** creds )
@@ -86,6 +92,20 @@ def file_storage(provider: FileStorageProvider):
8692 - 1 ,
8793 os .path .getsize (TEST_CONSTANTS .READ_TEXT_FILE ),
8894 ),
95+ (
96+ file_storage (provider = FileStorageProvider .S3 ),
97+ TEST_CONSTANTS .READ_TEXT_FILE ,
98+ "rb" ,
99+ 0 ,
100+ os .path .getsize (TEST_CONSTANTS .READ_TEXT_FILE ),
101+ ),
102+ (
103+ file_storage (provider = FileStorageProvider .AZURE ),
104+ TEST_CONSTANTS .READ_TEXT_FILE ,
105+ "rb" ,
106+ 0 ,
107+ os .path .getsize (TEST_CONSTANTS .READ_TEXT_FILE ),
108+ ),
89109 ],
90110)
91111def test_file_read (file_storage , path , mode , read_length , expected_read_length ):
@@ -233,6 +253,46 @@ def test_file_read_exception(file_storage, path, mode, read_length):
233253 0 ,
234254 len (TEST_CONSTANTS .TEXT_CONTENT ),
235255 ),
256+ (
257+ file_storage (provider = FileStorageProvider .AZURE ),
258+ TEST_CONSTANTS .READ_PDF_FILE ,
259+ "rb" ,
260+ None ,
261+ TEST_CONSTANTS .WRITE_PDF_FILE ,
262+ "wb" ,
263+ - 1 ,
264+ os .path .getsize (TEST_CONSTANTS .READ_PDF_FILE ),
265+ ),
266+ (
267+ file_storage (provider = FileStorageProvider .AZURE ),
268+ TEST_CONSTANTS .READ_TEXT_FILE ,
269+ "rb" ,
270+ None ,
271+ TEST_CONSTANTS .WRITE_TEXT_FILE ,
272+ "wb" ,
273+ 0 ,
274+ 0 ,
275+ ),
276+ (
277+ file_storage (provider = FileStorageProvider .AZURE ),
278+ TEST_CONSTANTS .READ_TEXT_FILE ,
279+ "rb" ,
280+ None ,
281+ TEST_CONSTANTS .WRITE_TEXT_FILE ,
282+ "wb" ,
283+ 0 ,
284+ 0 ,
285+ ),
286+ (
287+ file_storage (provider = FileStorageProvider .AZURE ),
288+ None ,
289+ "rb" ,
290+ TEST_CONSTANTS .TEXT_CONTENT ,
291+ TEST_CONSTANTS .WRITE_TEXT_FILE ,
292+ "w" ,
293+ 0 ,
294+ len (TEST_CONSTANTS .TEXT_CONTENT ),
295+ ),
236296 ],
237297)
238298def test_file_write (
@@ -284,6 +344,11 @@ def test_file_write(
284344 # as they only support creating buckets. For
285345 # further details pls check implementation of mkdir in S3
286346 ),
347+ (
348+ file_storage (provider = FileStorageProvider .AZURE ),
349+ TEST_CONSTANTS .TEST_FOLDER ,
350+ False ,
351+ ),
287352 ],
288353)
289354def test_make_dir (file_storage , folder_path , expected_result ):
@@ -316,6 +381,11 @@ def test_make_dir(file_storage, folder_path, expected_result):
316381 TEST_CONSTANTS .GCS_BUCKET ,
317382 True ,
318383 ),
384+ (
385+ file_storage (provider = FileStorageProvider .AZURE ),
386+ TEST_CONSTANTS .GCS_BUCKET ,
387+ True ,
388+ ),
319389 ],
320390)
321391def test_path_exists (file_storage , folder_path , expected_result ):
@@ -345,6 +415,11 @@ def test_path_exists(file_storage, folder_path, expected_result):
345415 TEST_CONSTANTS .READ_FOLDER_PATH ,
346416 2 ,
347417 ),
418+ (
419+ file_storage (provider = FileStorageProvider .AZURE ),
420+ TEST_CONSTANTS .READ_FOLDER_PATH ,
421+ 2 ,
422+ ),
348423 ],
349424)
350425def test_ls (file_storage , folder_path , expected_file_count ):
@@ -366,6 +441,10 @@ def test_ls(file_storage, folder_path, expected_file_count):
366441 file_storage (provider = FileStorageProvider .MINIO ),
367442 TEST_CONSTANTS .WRITE_FOLDER_PATH ,
368443 ),
444+ (
445+ file_storage (provider = FileStorageProvider .AZURE ),
446+ TEST_CONSTANTS .WRITE_FOLDER_PATH ,
447+ ),
369448 ],
370449)
371450def test_rm (file_storage , folder_path ):
@@ -661,6 +740,11 @@ def test_file_mime_type(file_storage, path, read_length, expected_mime_type):
661740 TEST_CONSTANTS .READ_TEXT_FILE ,
662741 TEST_CONSTANTS .TEST_FOLDER + "/3.txt" ,
663742 ),
743+ (
744+ file_storage (provider = FileStorageProvider .AZURE ),
745+ TEST_CONSTANTS .READ_TEXT_FILE ,
746+ TEST_CONSTANTS .TEST_FOLDER + "/3.txt" ,
747+ ),
664748 ],
665749)
666750def test_download (file_storage , from_path , to_path ):
@@ -690,6 +774,11 @@ def test_download(file_storage, from_path, to_path):
690774 TEST_CONSTANTS .READ_TEXT_FILE ,
691775 TEST_CONSTANTS .TEST_FOLDER + "/3.txt" ,
692776 ),
777+ (
778+ file_storage (provider = FileStorageProvider .AZURE ),
779+ TEST_CONSTANTS .READ_TEXT_FILE ,
780+ TEST_CONSTANTS .TEST_FOLDER + "/3.txt" ,
781+ ),
693782 ],
694783)
695784def test_upload (file_storage , from_path , to_path ):
@@ -719,6 +808,11 @@ def test_upload(file_storage, from_path, to_path):
719808 TEST_CONSTANTS .READ_TEXT_FILE ,
720809 "4a08b5721f75657eb883202cae16c74ca62df2c605e4126e50f4bf341d4fd693" ,
721810 ),
811+ (
812+ file_storage (provider = FileStorageProvider .AZURE ),
813+ TEST_CONSTANTS .READ_TEXT_FILE ,
814+ "4a08b5721f75657eb883202cae16c74ca62df2c605e4126e50f4bf341d4fd693" ,
815+ ),
722816 ],
723817)
724818def test_get_hash_from_file (file_storage , file_path , expected_result ):
@@ -744,6 +838,11 @@ def test_get_hash_from_file(file_storage, file_path, expected_result):
744838 TEST_CONSTANTS .READ_FOLDER_PATH + "/*.pdf" ,
745839 1 ,
746840 ),
841+ (
842+ file_storage (provider = FileStorageProvider .AZURE ),
843+ TEST_CONSTANTS .READ_FOLDER_PATH + "/*.pdf" ,
844+ 1 ,
845+ ),
747846 ],
748847)
749848def test_glob (file_storage , folder_path , expected_result ):
@@ -757,7 +856,7 @@ def test_glob(file_storage, folder_path, expected_result):
757856 [
758857 (
759858 StorageType .PERMANENT ,
760- "TEST_PERMANENT_STORAGE " ,
859+ "TEST_PERMANENT_STORAGE_GCS " ,
761860 FileStorageProvider .GCS ,
762861 ),
763862 (
@@ -770,6 +869,11 @@ def test_glob(file_storage, folder_path, expected_result):
770869 "TEST_LOCAL_STORAGE" ,
771870 FileStorageProvider .LOCAL ,
772871 ),
872+ (
873+ StorageType .PERMANENT ,
874+ "TEST_PERMANENT_STORAGE_AZURE" ,
875+ FileStorageProvider .AZURE ,
876+ ),
773877 ],
774878)
775879def test_get_storage (storage_type , env_name , expected ):
@@ -783,7 +887,7 @@ def test_get_storage(storage_type, env_name, expected):
783887 [
784888 (
785889 StorageType .PERMANENT ,
786- "TEST_PERMANENT_STORAGE " ,
890+ "TEST_PERMANENT_STORAGE_GCS " ,
787891 "fsspec-test" ,
788892 ),
789893 (
0 commit comments