File tree Expand file tree Collapse file tree
packages/google-api-core/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -323,6 +323,22 @@ async def test_async_upload_request_body_argument_overrides_session_default(
323323 assert start_kwargs ["data" ] == expected
324324
325325
326+ @pytest .mark .asyncio
327+ async def test_async_upload_request_body_positional_override () -> None :
328+ """Verifies request_body remains the second positional parameter of upload()."""
329+ async_transport = _make_single_chunk_async_transport ()
330+ session = AsyncResumableUploadSession (
331+ upload_url = "https://api.example.com/start" ,
332+ transport = async_transport ,
333+ request_body = '{"name": "from-init"}' ,
334+ )
335+
336+ await session .upload (b"payload" , '{"name": "positional"}' )
337+
338+ _ , _ , start_kwargs = async_transport .requests [0 ]
339+ assert start_kwargs ["data" ] == b'{"name": "positional"}'
340+
341+
326342@pytest .mark .asyncio
327343async def test_async_upload_request_body_defaults_to_empty () -> None :
328344 """Verifies the start request carries an empty payload when no request_body is configured."""
Original file line number Diff line number Diff line change @@ -444,6 +444,22 @@ def test_sync_upload_request_body_argument_overrides_session_default(
444444 assert start_call .kwargs ["data" ] == expected
445445
446446
447+ def test_sync_upload_request_body_positional_override ():
448+ # request_body stays the second positional parameter, so callers that
449+ # pass it positionally are not broken by the constructor default.
450+ session_transport = _make_single_chunk_sync_transport ()
451+ session = ResumableUploadSession (
452+ upload_url = "https://api.example.com/start" ,
453+ transport = session_transport ,
454+ request_body = '{"name": "from-init"}' ,
455+ )
456+
457+ session .upload (b"payload" , '{"name": "positional"}' )
458+
459+ start_call = session_transport .request .call_args_list [0 ]
460+ assert start_call .kwargs ["data" ] == b'{"name": "positional"}'
461+
462+
447463def test_sync_upload_request_body_defaults_to_empty ():
448464 # Without a request_body on the constructor or the call, the start
449465 # request carries an empty payload.
You can’t perform that action at this time.
0 commit comments