@@ -862,7 +862,7 @@ def test_execute_command_forwards_allowed_local_paths(
862862 enforce_embedded_schema_correctness = False ,
863863 )
864864 stmt .set_staging_allowed_local_paths .assert_called_once_with (
865- expected if uses_paths else []
865+ expected if uses_paths else [], input_stream_token = "__input_stream__"
866866 )
867867 (stmt .submit if async_op else stmt .execute ).assert_called_once ()
868868
@@ -912,7 +912,9 @@ def execute():
912912 stmt .set_staging_allowed_local_paths .assert_not_called ()
913913 else :
914914 execute ()
915- stmt .set_staging_allowed_local_paths .assert_called_once_with ([])
915+ stmt .set_staging_allowed_local_paths .assert_called_once_with (
916+ [], input_stream_token = "__input_stream__"
917+ )
916918 stmt .execute .assert_called_once ()
917919
918920
@@ -947,30 +949,34 @@ def test_staging_verb_matches_only_the_leading_statement(operation, expected):
947949 assert kernel_client ._staging_verb (stripped ) == expected
948950
949951
950- @pytest .mark .parametrize (
951- "query" ,
952- [
953- "PUT '__input_stream__' INTO '/Volumes/c/s/v/file'" ,
954- "put '__input_stream__' INTO '/Volumes/c/s/v/file'" ,
955- "PUT '__input_stream__'INTO '/Volumes/c/s/v/file'" ,
956- 'PUT"__input_stream__"INTO "/Volumes/c/s/v/file"' ,
957- "/* upload */ PUT '__input_stream__' INTO '/Volumes/c/s/v/file'" ,
958- "/* outer /* inner */ outer */ PUT '__input_stream__' INTO '/Volumes/c/s/v/file'" ,
959- "PUT'__input_stream__' INTO '/Volumes/c/s/v/file'" ,
960- "PUT /* upload */ '__input_stream__' INTO '/Volumes/c/s/v/file'" ,
961- "PUT\n -- upload\n '__input_stream__' INTO '/Volumes/c/s/v/file'" ,
962- "/* upload */ PUT\" __input_stream__\" INTO '/Volumes/c/s/v/file'" ,
963- ],
964- )
965- def test_kernel_rejects_streaming_put (query ):
952+ def test_kernel_rejects_decoded_streaming_put ():
966953 c = _make_client ()
967954 c ._kernel_session = MagicMock ()
955+ stmt = c ._kernel_session .statement .return_value
956+ error = _FakeKernelError (
957+ code = "InvalidArgument" , message = "Streaming PUT is not supported"
958+ )
959+ error .error_code = "FILE_TRANSFER_UNSUPPORTED_STREAM"
960+ stmt .execute .side_effect = error
961+ cursor = MagicMock ()
962+ cursor .connection .staging_allowed_local_path = None
968963 with pytest .raises (NotSupportedError , match = "Streaming PUT" ):
969964 c .execute_command (
970- query , MagicMock (), 1 , 1 , False , MagicMock (), False , [], False , False
965+ "PUT r'__input_stream__' INTO '/Volumes/c/s/v/file'" ,
966+ MagicMock (),
967+ 1 ,
968+ 1 ,
969+ False ,
970+ cursor ,
971+ False ,
972+ [],
973+ False ,
974+ False ,
971975 )
972- stmt = c ._kernel_session .statement .return_value
973- stmt .execute .assert_not_called ()
976+ stmt .set_staging_allowed_local_paths .assert_called_once_with (
977+ [], input_stream_token = "__input_stream__"
978+ )
979+ stmt .execute .assert_called_once ()
974980 stmt .close .assert_called_once ()
975981
976982
0 commit comments