@@ -746,35 +746,44 @@ def test_get_empty_file(tmp_path, conn_cnx):
746
746
assert not empty_file .exists ()
747
747
748
748
749
+ @pytest .mark .parametrize ("auto_compress" , ["TRUE" , "FALSE" ])
749
750
@pytest .mark .skipolddriver
750
751
@pytest .mark .skipif (IS_WINDOWS , reason = "not supported on Windows" )
751
- def test_get_file_permission (tmp_path , conn_cnx , caplog ):
752
+ def test_get_file_permission (tmp_path , conn_cnx , caplog , auto_compress ):
752
753
test_file = tmp_path / "data.csv"
753
754
test_file .write_text ("1,2,3\n " )
754
755
stage_name = random_string (5 , "test_get_file_permission_" )
756
+
755
757
with conn_cnx () as cnx :
756
758
with cnx .cursor () as cur :
757
759
cur .execute (f"create temporary stage { stage_name } " )
758
760
filename_in_put = str (test_file ).replace ("\\ " , "/" )
759
761
cur .execute (
760
- f"PUT 'file://{ filename_in_put } ' @{ stage_name } AUTO_COMPRESS=FALSE " ,
762
+ f"PUT 'file://{ filename_in_put } ' @{ stage_name } AUTO_COMPRESS={ auto_compress } " ,
761
763
)
764
+ test_file .unlink ()
762
765
763
766
with caplog .at_level (logging .ERROR ):
764
767
cur .execute (f"GET @{ stage_name } /data.csv file://{ tmp_path } " )
765
768
assert "FileNotFoundError" not in caplog .text
769
+ assert len (list (tmp_path .iterdir ())) == 1
770
+ downloaded_file = next (tmp_path .iterdir ())
766
771
767
772
default_mask = os .umask (0 )
768
773
os .umask (default_mask )
769
774
770
775
assert (
771
- oct (os .stat (test_file ).st_mode )[- 3 :] == oct (0o600 & ~ default_mask )[- 3 :]
776
+ oct (os .stat (downloaded_file ).st_mode )[- 3 :]
777
+ == oct (0o600 & ~ default_mask )[- 3 :]
772
778
)
773
779
774
780
781
+ @pytest .mark .parametrize ("auto_compress" , ["TRUE" , "FALSE" ])
775
782
@pytest .mark .skipolddriver
776
783
@pytest .mark .skipif (IS_WINDOWS , reason = "not supported on Windows" )
777
- def test_get_unsafe_file_permission_when_flag_set (tmp_path , conn_cnx , caplog ):
784
+ def test_get_unsafe_file_permission_when_flag_set (
785
+ tmp_path , conn_cnx , caplog , auto_compress
786
+ ):
778
787
test_file = tmp_path / "data.csv"
779
788
test_file .write_text ("1,2,3\n " )
780
789
stage_name = random_string (5 , "test_get_file_permission_" )
@@ -784,20 +793,24 @@ def test_get_unsafe_file_permission_when_flag_set(tmp_path, conn_cnx, caplog):
784
793
cur .execute (f"create temporary stage { stage_name } " )
785
794
filename_in_put = str (test_file ).replace ("\\ " , "/" )
786
795
cur .execute (
787
- f"PUT 'file://{ filename_in_put } ' @{ stage_name } AUTO_COMPRESS=FALSE " ,
796
+ f"PUT 'file://{ filename_in_put } ' @{ stage_name } AUTO_COMPRESS={ auto_compress } " ,
788
797
)
798
+ test_file .unlink ()
789
799
790
800
with caplog .at_level (logging .ERROR ):
791
801
cur .execute (f"GET @{ stage_name } /data.csv file://{ tmp_path } " )
792
802
assert "FileNotFoundError" not in caplog .text
803
+ assert len (list (tmp_path .iterdir ())) == 1
804
+ downloaded_file = next (tmp_path .iterdir ())
793
805
794
806
# get the default mask, usually it is 0o022
795
807
default_mask = os .umask (0 )
796
808
os .umask (default_mask )
797
809
# files by default are given the permission 644 (Octal)
798
810
# umask is for denial, we need to negate
799
811
assert (
800
- oct (os .stat (test_file ).st_mode )[- 3 :] == oct (0o666 & ~ default_mask )[- 3 :]
812
+ oct (os .stat (downloaded_file ).st_mode )[- 3 :]
813
+ == oct (0o666 & ~ default_mask )[- 3 :]
801
814
)
802
815
cnx .unsafe_file_write = False
803
816
0 commit comments