@@ -667,29 +667,31 @@ def test_staging_ingestion_life_cycle(self):
667
667
query = f"PUT '{ temp_path } ' INTO 'stage://tmp/{ self .staging_ingestion_user } /tmp/11/15/file1.csv' OVERWRITE"
668
668
cursor .execute (query )
669
669
670
- # GET should succeed
670
+ # GET should succeed
671
671
672
- new_fh , new_temp_path = tempfile .mkstemp ()
672
+ new_fh , new_temp_path = tempfile .mkstemp ()
673
673
674
+ with self .connection (extra_params = {"uploads_base_path" : new_temp_path }) as conn :
674
675
cursor = conn .cursor ()
675
676
query = f"GET 'stage://tmp/{ self .staging_ingestion_user } /tmp/11/15/file1.csv' TO '{ new_temp_path } '"
676
677
cursor .execute (query )
677
678
678
- with open (new_fh , "rb" ) as fp :
679
- fetched_text = fp .read ()
679
+ with open (new_fh , "rb" ) as fp :
680
+ fetched_text = fp .read ()
680
681
681
- assert fetched_text == original_text
682
+ assert fetched_text == original_text
682
683
683
- # REMOVE should succeed
684
+ # REMOVE should succeed
684
685
685
- remove_query = (
686
- f"REMOVE 'stage://tmp/{ self .staging_ingestion_user } /tmp/11/15/file1.csv'"
687
- )
686
+ remove_query = (
687
+ f"REMOVE 'stage://tmp/{ self .staging_ingestion_user } /tmp/11/15/file1.csv'"
688
+ )
688
689
690
+ with self .connection (extra_params = {"uploads_base_path" : "/" }) as conn :
689
691
cursor = conn .cursor ()
690
692
cursor .execute (remove_query )
691
693
692
- # GET after REMOVE should fail
694
+ # GET after REMOVE should fail
693
695
694
696
with pytest .raises (Error ):
695
697
cursor = conn .cursor ()
@@ -718,6 +720,27 @@ def test_staging_ingestion_put_fails_without_uploadsbasepath(self):
718
720
query = f"PUT '{ temp_path } ' INTO 'stage://tmp/{ self .staging_ingestion_user } /tmp/11/15/file1.csv' OVERWRITE"
719
721
cursor .execute (query )
720
722
723
+ def test_staging_ingestion_put_fails_if_localFile_not_in_uploads_base_path (self ):
724
+
725
+
726
+ fh , temp_path = tempfile .mkstemp ()
727
+
728
+ original_text = "hello world!" .encode ("utf-8" )
729
+
730
+ with open (fh , "wb" ) as fp :
731
+ fp .write (original_text )
732
+
733
+ base_path , filename = os .path .split (temp_path )
734
+
735
+ # Add junk to base_path
736
+ base_path = os .path .join (base_path , "temp" )
737
+
738
+ with pytest .raises (Error ):
739
+ with self .connection (extra_params = {"uploads_base_path" : base_path }) as conn :
740
+ cursor = conn .cursor ()
741
+ query = f"PUT '{ temp_path } ' INTO 'stage://tmp/{ self .staging_ingestion_user } /tmp/11/15/file1.csv' OVERWRITE"
742
+ cursor .execute (query )
743
+
721
744
722
745
def main (cli_args ):
723
746
global get_args_from_env
0 commit comments