@@ -402,7 +402,7 @@ async def test_upload_from_file(
402402
403403 http_client = AsyncMock ()
404404 mock_response = create_mock_httpx_response ()
405- http_client .put = AsyncMock (return_value = mock_response )
405+ http_client .send = AsyncMock (return_value = mock_response )
406406 mock_async_client ._client = http_client
407407
408408 ops = AsyncStorageObjectOps (mock_async_client )
@@ -416,57 +416,8 @@ async def test_upload_from_file(
416416 metadata = None ,
417417 ttl_ms = None ,
418418 )
419- http_client .put .assert_awaited_once_with (object_view .upload_url , content = b"test content" )
420- mock_async_client .objects .complete .assert_awaited_once ()
421-
422- @pytest .mark .asyncio
423- async def test_upload_from_text (self , mock_async_client : AsyncMock , object_view : MockObjectView ) -> None :
424- """Test upload_from_text method."""
425- mock_async_client .objects .create = AsyncMock (return_value = object_view )
426- mock_async_client .objects .complete = AsyncMock (return_value = object_view )
427-
428- http_client = AsyncMock ()
429- mock_response = create_mock_httpx_response ()
430- http_client .put = AsyncMock (return_value = mock_response )
431- mock_async_client ._client = http_client
432-
433- ops = AsyncStorageObjectOps (mock_async_client )
434- obj = await ops .upload_from_text ("test content" , name = "test.txt" , metadata = {"key" : "value" })
435-
436- assert isinstance (obj , AsyncStorageObject )
437- assert obj .id == "obj_123"
438- mock_async_client .objects .create .assert_awaited_once_with (
439- name = "test.txt" ,
440- content_type = "text" ,
441- metadata = {"key" : "value" },
442- ttl_ms = None ,
443- )
444- http_client .put .assert_awaited_once_with (object_view .upload_url , content = "test content" )
445- mock_async_client .objects .complete .assert_awaited_once ()
446-
447- @pytest .mark .asyncio
448- async def test_upload_from_bytes (self , mock_async_client : AsyncMock , object_view : MockObjectView ) -> None :
449- """Test upload_from_bytes method."""
450- mock_async_client .objects .create = AsyncMock (return_value = object_view )
451- mock_async_client .objects .complete = AsyncMock (return_value = object_view )
452-
453- http_client = AsyncMock ()
454- mock_response = create_mock_httpx_response ()
455- http_client .put = AsyncMock (return_value = mock_response )
456- mock_async_client ._client = http_client
457-
458- ops = AsyncStorageObjectOps (mock_async_client )
459- obj = await ops .upload_from_bytes (b"test content" , name = "test.bin" , content_type = "binary" )
460-
461- assert isinstance (obj , AsyncStorageObject )
462- assert obj .id == "obj_123"
463- mock_async_client .objects .create .assert_awaited_once_with (
464- name = "test.bin" ,
465- content_type = "binary" ,
466- metadata = None ,
467- ttl_ms = None ,
468- )
469- http_client .put .assert_awaited_once_with (object_view .upload_url , content = b"test content" )
419+ assert http_client .send .call_count == 1
420+ assert http_client .send .call_args [0 ][0 ].read () == b"test content"
470421 mock_async_client .objects .complete .assert_awaited_once ()
471422
472423 @pytest .mark .asyncio
@@ -506,7 +457,7 @@ async def test_upload_from_dir(
506457
507458 http_client = AsyncMock ()
508459 mock_response = create_mock_httpx_response ()
509- http_client .put = AsyncMock (return_value = mock_response )
460+ http_client .send = AsyncMock (return_value = mock_response )
510461 mock_async_client ._client = http_client
511462
512463 ops = AsyncStorageObjectOps (mock_async_client )
@@ -520,13 +471,13 @@ async def test_upload_from_dir(
520471 metadata = {"key" : "value" },
521472 ttl_ms = None ,
522473 )
523- # Verify that put was called with tarball content
524- http_client .put .assert_awaited_once ()
525- call_args = http_client .put .call_args
526- assert call_args [0 ][0 ] == object_view .upload_url
474+ # Verify that a request was sent with tarball content
475+ http_client .send .assert_awaited_once ()
476+ call_args = http_client .send .call_args
477+ assert str ( call_args [0 ][0 ]. url ) == object_view .upload_url
527478
528479 # Verify it's a valid gzipped tarball
529- uploaded_content = call_args [1 ][ "content" ]
480+ uploaded_content = call_args [0 ][ 0 ]. read ()
530481 with tarfile .open (fileobj = io .BytesIO (uploaded_content ), mode = "r:gz" ) as tar :
531482 members = tar .getmembers ()
532483 member_names = [m .name for m in members ]
@@ -555,7 +506,7 @@ async def test_upload_from_dir_with_inline_ignore_patterns(
555506
556507 http_client = AsyncMock ()
557508 mock_response = create_mock_httpx_response ()
558- http_client .put = AsyncMock (return_value = mock_response )
509+ http_client .send = AsyncMock (return_value = mock_response )
559510 mock_async_client ._client = http_client
560511
561512 client = AsyncStorageObjectOps (mock_async_client )
@@ -569,7 +520,7 @@ def ignore_logs_and_build(ti: tarfile.TarInfo) -> tarfile.TarInfo | None:
569520 obj = await client .upload_from_dir (test_dir , ignore = ignore_logs_and_build )
570521
571522 assert isinstance (obj , AsyncStorageObject )
572- uploaded_content = http_client .put .call_args [1 ][ "content" ]
523+ uploaded_content = http_client .send .call_args [0 ][ 0 ]. read ()
573524
574525 with tarfile .open (fileobj = io .BytesIO (uploaded_content ), mode = "r:gz" ) as tar :
575526 names = {m .name for m in tar .getmembers ()}
@@ -592,7 +543,7 @@ async def test_upload_from_dir_default_name(
592543
593544 http_client = AsyncMock ()
594545 mock_response = create_mock_httpx_response ()
595- http_client .put = AsyncMock (return_value = mock_response )
546+ http_client .send = AsyncMock (return_value = mock_response )
596547 mock_async_client ._client = http_client
597548
598549 ops = AsyncStorageObjectOps (mock_async_client )
@@ -623,7 +574,7 @@ async def test_upload_from_dir_with_ttl(
623574
624575 http_client = AsyncMock ()
625576 mock_response = create_mock_httpx_response ()
626- http_client .put = AsyncMock (return_value = mock_response )
577+ http_client .send = AsyncMock (return_value = mock_response )
627578 mock_async_client ._client = http_client
628579
629580 ops = AsyncStorageObjectOps (mock_async_client )
@@ -650,7 +601,7 @@ async def test_upload_from_dir_empty_directory(
650601
651602 http_client = AsyncMock ()
652603 mock_response = create_mock_httpx_response ()
653- http_client .put = AsyncMock (return_value = mock_response )
604+ http_client .send = AsyncMock (return_value = mock_response )
654605 mock_async_client ._client = http_client
655606
656607 ops = AsyncStorageObjectOps (mock_async_client )
@@ -664,7 +615,7 @@ async def test_upload_from_dir_empty_directory(
664615 metadata = None ,
665616 ttl_ms = None ,
666617 )
667- http_client .put .assert_awaited_once ()
618+ http_client .send .assert_awaited_once ()
668619 mock_async_client .objects .complete .assert_awaited_once ()
669620
670621 @pytest .mark .asyncio
@@ -681,7 +632,7 @@ async def test_upload_from_dir_with_string_path(
681632
682633 http_client = AsyncMock ()
683634 mock_response = create_mock_httpx_response ()
684- http_client .put = AsyncMock (return_value = mock_response )
635+ http_client .send = AsyncMock (return_value = mock_response )
685636 mock_async_client ._client = http_client
686637
687638 ops = AsyncStorageObjectOps (mock_async_client )
@@ -696,7 +647,7 @@ async def test_upload_from_dir_with_string_path(
696647 metadata = None ,
697648 ttl_ms = None ,
698649 )
699- http_client .put .assert_awaited_once ()
650+ http_client .send .assert_awaited_once ()
700651 mock_async_client .objects .complete .assert_awaited_once ()
701652
702653
0 commit comments