@@ -749,20 +749,30 @@ def test_parse_retry_after_header(
749749 @mock .patch ("moderation_api._base_client.BaseClient._calculate_retry_timeout" , _low_retry_timeout )
750750 @pytest .mark .respx (base_url = base_url )
751751 def test_retrying_timeout_errors_doesnt_leak (self , respx_mock : MockRouter , client : ModerationAPI ) -> None :
752- respx_mock .get ("/authors " ).mock (side_effect = httpx .TimeoutException ("Test timeout error" ))
752+ respx_mock .post ("/moderate " ).mock (side_effect = httpx .TimeoutException ("Test timeout error" ))
753753
754754 with pytest .raises (APITimeoutError ):
755- client .authors .with_streaming_response .list ().__enter__ ()
755+ client .content .with_streaming_response .submit (
756+ content = {
757+ "text" : "x" ,
758+ "type" : "text" ,
759+ }
760+ ).__enter__ ()
756761
757762 assert _get_open_connections (client ) == 0
758763
759764 @mock .patch ("moderation_api._base_client.BaseClient._calculate_retry_timeout" , _low_retry_timeout )
760765 @pytest .mark .respx (base_url = base_url )
761766 def test_retrying_status_errors_doesnt_leak (self , respx_mock : MockRouter , client : ModerationAPI ) -> None :
762- respx_mock .get ("/authors " ).mock (return_value = httpx .Response (500 ))
767+ respx_mock .post ("/moderate " ).mock (return_value = httpx .Response (500 ))
763768
764769 with pytest .raises (APIStatusError ):
765- client .authors .with_streaming_response .list ().__enter__ ()
770+ client .content .with_streaming_response .submit (
771+ content = {
772+ "text" : "x" ,
773+ "type" : "text" ,
774+ }
775+ ).__enter__ ()
766776 assert _get_open_connections (client ) == 0
767777
768778 @pytest .mark .parametrize ("failures_before_success" , [0 , 2 , 4 ])
@@ -789,9 +799,14 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
789799 return httpx .Response (500 )
790800 return httpx .Response (200 )
791801
792- respx_mock .get ("/authors " ).mock (side_effect = retry_handler )
802+ respx_mock .post ("/moderate " ).mock (side_effect = retry_handler )
793803
794- response = client .authors .with_raw_response .list ()
804+ response = client .content .with_raw_response .submit (
805+ content = {
806+ "text" : "x" ,
807+ "type" : "text" ,
808+ }
809+ )
795810
796811 assert response .retries_taken == failures_before_success
797812 assert int (response .http_request .headers .get ("x-stainless-retry-count" )) == failures_before_success
@@ -813,9 +828,15 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
813828 return httpx .Response (500 )
814829 return httpx .Response (200 )
815830
816- respx_mock .get ("/authors " ).mock (side_effect = retry_handler )
831+ respx_mock .post ("/moderate " ).mock (side_effect = retry_handler )
817832
818- response = client .authors .with_raw_response .list (extra_headers = {"x-stainless-retry-count" : Omit ()})
833+ response = client .content .with_raw_response .submit (
834+ content = {
835+ "text" : "x" ,
836+ "type" : "text" ,
837+ },
838+ extra_headers = {"x-stainless-retry-count" : Omit ()},
839+ )
819840
820841 assert len (response .http_request .headers .get_list ("x-stainless-retry-count" )) == 0
821842
@@ -836,9 +857,15 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
836857 return httpx .Response (500 )
837858 return httpx .Response (200 )
838859
839- respx_mock .get ("/authors " ).mock (side_effect = retry_handler )
860+ respx_mock .post ("/moderate " ).mock (side_effect = retry_handler )
840861
841- response = client .authors .with_raw_response .list (extra_headers = {"x-stainless-retry-count" : "42" })
862+ response = client .content .with_raw_response .submit (
863+ content = {
864+ "text" : "x" ,
865+ "type" : "text" ,
866+ },
867+ extra_headers = {"x-stainless-retry-count" : "42" },
868+ )
842869
843870 assert response .http_request .headers .get ("x-stainless-retry-count" ) == "42"
844871
@@ -1592,10 +1619,15 @@ async def test_parse_retry_after_header(
15921619 async def test_retrying_timeout_errors_doesnt_leak (
15931620 self , respx_mock : MockRouter , async_client : AsyncModerationAPI
15941621 ) -> None :
1595- respx_mock .get ("/authors " ).mock (side_effect = httpx .TimeoutException ("Test timeout error" ))
1622+ respx_mock .post ("/moderate " ).mock (side_effect = httpx .TimeoutException ("Test timeout error" ))
15961623
15971624 with pytest .raises (APITimeoutError ):
1598- await async_client .authors .with_streaming_response .list ().__aenter__ ()
1625+ await async_client .content .with_streaming_response .submit (
1626+ content = {
1627+ "text" : "x" ,
1628+ "type" : "text" ,
1629+ }
1630+ ).__aenter__ ()
15991631
16001632 assert _get_open_connections (async_client ) == 0
16011633
@@ -1604,10 +1636,15 @@ async def test_retrying_timeout_errors_doesnt_leak(
16041636 async def test_retrying_status_errors_doesnt_leak (
16051637 self , respx_mock : MockRouter , async_client : AsyncModerationAPI
16061638 ) -> None :
1607- respx_mock .get ("/authors " ).mock (return_value = httpx .Response (500 ))
1639+ respx_mock .post ("/moderate " ).mock (return_value = httpx .Response (500 ))
16081640
16091641 with pytest .raises (APIStatusError ):
1610- await async_client .authors .with_streaming_response .list ().__aenter__ ()
1642+ await async_client .content .with_streaming_response .submit (
1643+ content = {
1644+ "text" : "x" ,
1645+ "type" : "text" ,
1646+ }
1647+ ).__aenter__ ()
16111648 assert _get_open_connections (async_client ) == 0
16121649
16131650 @pytest .mark .parametrize ("failures_before_success" , [0 , 2 , 4 ])
@@ -1634,9 +1671,14 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16341671 return httpx .Response (500 )
16351672 return httpx .Response (200 )
16361673
1637- respx_mock .get ("/authors " ).mock (side_effect = retry_handler )
1674+ respx_mock .post ("/moderate " ).mock (side_effect = retry_handler )
16381675
1639- response = await client .authors .with_raw_response .list ()
1676+ response = await client .content .with_raw_response .submit (
1677+ content = {
1678+ "text" : "x" ,
1679+ "type" : "text" ,
1680+ }
1681+ )
16401682
16411683 assert response .retries_taken == failures_before_success
16421684 assert int (response .http_request .headers .get ("x-stainless-retry-count" )) == failures_before_success
@@ -1658,9 +1700,15 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16581700 return httpx .Response (500 )
16591701 return httpx .Response (200 )
16601702
1661- respx_mock .get ("/authors " ).mock (side_effect = retry_handler )
1703+ respx_mock .post ("/moderate " ).mock (side_effect = retry_handler )
16621704
1663- response = await client .authors .with_raw_response .list (extra_headers = {"x-stainless-retry-count" : Omit ()})
1705+ response = await client .content .with_raw_response .submit (
1706+ content = {
1707+ "text" : "x" ,
1708+ "type" : "text" ,
1709+ },
1710+ extra_headers = {"x-stainless-retry-count" : Omit ()},
1711+ )
16641712
16651713 assert len (response .http_request .headers .get_list ("x-stainless-retry-count" )) == 0
16661714
@@ -1681,9 +1729,15 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16811729 return httpx .Response (500 )
16821730 return httpx .Response (200 )
16831731
1684- respx_mock .get ("/authors " ).mock (side_effect = retry_handler )
1732+ respx_mock .post ("/moderate " ).mock (side_effect = retry_handler )
16851733
1686- response = await client .authors .with_raw_response .list (extra_headers = {"x-stainless-retry-count" : "42" })
1734+ response = await client .content .with_raw_response .submit (
1735+ content = {
1736+ "text" : "x" ,
1737+ "type" : "text" ,
1738+ },
1739+ extra_headers = {"x-stainless-retry-count" : "42" },
1740+ )
16871741
16881742 assert response .http_request .headers .get ("x-stainless-retry-count" ) == "42"
16891743
0 commit comments