@@ -931,22 +931,24 @@ def test_parse_retry_after_header(
931931 @mock .patch ("sent_dm._base_client.BaseClient._calculate_retry_timeout" , _low_retry_timeout )
932932 @pytest .mark .respx (base_url = base_url )
933933 def test_retrying_timeout_errors_doesnt_leak (self , respx_mock : MockRouter , client : SentDm ) -> None :
934- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8" ).mock (
935- side_effect = httpx .TimeoutException ("Test timeout error" )
936- )
934+ respx_mock .post ("/v2/messages/phone" ).mock (side_effect = httpx .TimeoutException ("Test timeout error" ))
937935
938936 with pytest .raises (APITimeoutError ):
939- client .templates .with_streaming_response .delete ("7ba7b820-9dad-11d1-80b4-00c04fd430c8" ).__enter__ ()
937+ client .messages .with_streaming_response .send_to_phone (
938+ phone_number = "+1234567890" , template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
939+ ).__enter__ ()
940940
941941 assert _get_open_connections (client ) == 0
942942
943943 @mock .patch ("sent_dm._base_client.BaseClient._calculate_retry_timeout" , _low_retry_timeout )
944944 @pytest .mark .respx (base_url = base_url )
945945 def test_retrying_status_errors_doesnt_leak (self , respx_mock : MockRouter , client : SentDm ) -> None :
946- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (return_value = httpx .Response (500 ))
946+ respx_mock .post ("/v2/messages/phone " ).mock (return_value = httpx .Response (500 ))
947947
948948 with pytest .raises (APIStatusError ):
949- client .templates .with_streaming_response .delete ("7ba7b820-9dad-11d1-80b4-00c04fd430c8" ).__enter__ ()
949+ client .messages .with_streaming_response .send_to_phone (
950+ phone_number = "+1234567890" , template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
951+ ).__enter__ ()
950952 assert _get_open_connections (client ) == 0
951953
952954 @pytest .mark .parametrize ("failures_before_success" , [0 , 2 , 4 ])
@@ -973,9 +975,11 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
973975 return httpx .Response (500 )
974976 return httpx .Response (200 )
975977
976- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (side_effect = retry_handler )
978+ respx_mock .post ("/v2/messages/phone " ).mock (side_effect = retry_handler )
977979
978- response = client .templates .with_raw_response .delete ("7ba7b820-9dad-11d1-80b4-00c04fd430c8" )
980+ response = client .messages .with_raw_response .send_to_phone (
981+ phone_number = "+1234567890" , template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
982+ )
979983
980984 assert response .retries_taken == failures_before_success
981985 assert int (response .http_request .headers .get ("x-stainless-retry-count" )) == failures_before_success
@@ -997,10 +1001,12 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
9971001 return httpx .Response (500 )
9981002 return httpx .Response (200 )
9991003
1000- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (side_effect = retry_handler )
1004+ respx_mock .post ("/v2/messages/phone " ).mock (side_effect = retry_handler )
10011005
1002- response = client .templates .with_raw_response .delete (
1003- "7ba7b820-9dad-11d1-80b4-00c04fd430c8" , extra_headers = {"x-stainless-retry-count" : Omit ()}
1006+ response = client .messages .with_raw_response .send_to_phone (
1007+ phone_number = "+1234567890" ,
1008+ template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8" ,
1009+ extra_headers = {"x-stainless-retry-count" : Omit ()},
10041010 )
10051011
10061012 assert len (response .http_request .headers .get_list ("x-stainless-retry-count" )) == 0
@@ -1022,10 +1028,12 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
10221028 return httpx .Response (500 )
10231029 return httpx .Response (200 )
10241030
1025- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (side_effect = retry_handler )
1031+ respx_mock .post ("/v2/messages/phone " ).mock (side_effect = retry_handler )
10261032
1027- response = client .templates .with_raw_response .delete (
1028- "7ba7b820-9dad-11d1-80b4-00c04fd430c8" , extra_headers = {"x-stainless-retry-count" : "42" }
1033+ response = client .messages .with_raw_response .send_to_phone (
1034+ phone_number = "+1234567890" ,
1035+ template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8" ,
1036+ extra_headers = {"x-stainless-retry-count" : "42" },
10291037 )
10301038
10311039 assert response .http_request .headers .get ("x-stainless-retry-count" ) == "42"
@@ -1908,25 +1916,23 @@ async def test_parse_retry_after_header(
19081916 @mock .patch ("sent_dm._base_client.BaseClient._calculate_retry_timeout" , _low_retry_timeout )
19091917 @pytest .mark .respx (base_url = base_url )
19101918 async def test_retrying_timeout_errors_doesnt_leak (self , respx_mock : MockRouter , async_client : AsyncSentDm ) -> None :
1911- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8" ).mock (
1912- side_effect = httpx .TimeoutException ("Test timeout error" )
1913- )
1919+ respx_mock .post ("/v2/messages/phone" ).mock (side_effect = httpx .TimeoutException ("Test timeout error" ))
19141920
19151921 with pytest .raises (APITimeoutError ):
1916- await async_client .templates .with_streaming_response .delete (
1917- "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
1922+ await async_client .messages .with_streaming_response .send_to_phone (
1923+ phone_number = "+1234567890" , template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
19181924 ).__aenter__ ()
19191925
19201926 assert _get_open_connections (async_client ) == 0
19211927
19221928 @mock .patch ("sent_dm._base_client.BaseClient._calculate_retry_timeout" , _low_retry_timeout )
19231929 @pytest .mark .respx (base_url = base_url )
19241930 async def test_retrying_status_errors_doesnt_leak (self , respx_mock : MockRouter , async_client : AsyncSentDm ) -> None :
1925- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (return_value = httpx .Response (500 ))
1931+ respx_mock .post ("/v2/messages/phone " ).mock (return_value = httpx .Response (500 ))
19261932
19271933 with pytest .raises (APIStatusError ):
1928- await async_client .templates .with_streaming_response .delete (
1929- "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
1934+ await async_client .messages .with_streaming_response .send_to_phone (
1935+ phone_number = "+1234567890" , template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
19301936 ).__aenter__ ()
19311937 assert _get_open_connections (async_client ) == 0
19321938
@@ -1954,9 +1960,11 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
19541960 return httpx .Response (500 )
19551961 return httpx .Response (200 )
19561962
1957- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (side_effect = retry_handler )
1963+ respx_mock .post ("/v2/messages/phone " ).mock (side_effect = retry_handler )
19581964
1959- response = await client .templates .with_raw_response .delete ("7ba7b820-9dad-11d1-80b4-00c04fd430c8" )
1965+ response = await client .messages .with_raw_response .send_to_phone (
1966+ phone_number = "+1234567890" , template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8"
1967+ )
19601968
19611969 assert response .retries_taken == failures_before_success
19621970 assert int (response .http_request .headers .get ("x-stainless-retry-count" )) == failures_before_success
@@ -1978,10 +1986,12 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
19781986 return httpx .Response (500 )
19791987 return httpx .Response (200 )
19801988
1981- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (side_effect = retry_handler )
1989+ respx_mock .post ("/v2/messages/phone " ).mock (side_effect = retry_handler )
19821990
1983- response = await client .templates .with_raw_response .delete (
1984- "7ba7b820-9dad-11d1-80b4-00c04fd430c8" , extra_headers = {"x-stainless-retry-count" : Omit ()}
1991+ response = await client .messages .with_raw_response .send_to_phone (
1992+ phone_number = "+1234567890" ,
1993+ template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8" ,
1994+ extra_headers = {"x-stainless-retry-count" : Omit ()},
19851995 )
19861996
19871997 assert len (response .http_request .headers .get_list ("x-stainless-retry-count" )) == 0
@@ -2003,10 +2013,12 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
20032013 return httpx .Response (500 )
20042014 return httpx .Response (200 )
20052015
2006- respx_mock .delete ("/v2/templates/7ba7b820-9dad-11d1-80b4-00c04fd430c8 " ).mock (side_effect = retry_handler )
2016+ respx_mock .post ("/v2/messages/phone " ).mock (side_effect = retry_handler )
20072017
2008- response = await client .templates .with_raw_response .delete (
2009- "7ba7b820-9dad-11d1-80b4-00c04fd430c8" , extra_headers = {"x-stainless-retry-count" : "42" }
2018+ response = await client .messages .with_raw_response .send_to_phone (
2019+ phone_number = "+1234567890" ,
2020+ template_id = "7ba7b820-9dad-11d1-80b4-00c04fd430c8" ,
2021+ extra_headers = {"x-stainless-retry-count" : "42" },
20102022 )
20112023
20122024 assert response .http_request .headers .get ("x-stainless-retry-count" ) == "42"
0 commit comments