File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 1010from twilio .base .version import Version
1111from twilio .http .http_client import TwilioHttpClient
1212from twilio .http .response import Response
13+ from twilio .http .request import Request
1314
1415
1516class TestHttpClientRequest (unittest .TestCase ):
@@ -293,6 +294,25 @@ def test_session_not_preserved(self):
293294 self .assertEqual (response_2 .content , "response_2" )
294295
295296
297+ class TestTwilioRequest (unittest .TestCase ):
298+ def test_str (self ):
299+
300+ req = Request (
301+ method = "POST" ,
302+ url = "https://api.twilio.com/2010-04-01/Accounts.json" ,
303+ auth = ("AC123" , "token" ),
304+ params = {"PageSize" : "1" },
305+ data = {"FriendlyName" : "My New Account" },
306+ headers = {"X-Custom-Header" : "Value" },
307+ )
308+ expected = (
309+ "POST https://api.twilio.com/2010-04-01/Accounts.json?PageSize=1\n "
310+ " -d \" FriendlyName=My New Account\" \n "
311+ " -H \" X-Custom-Header: Value\" "
312+ )
313+ self .assertEqual (expected , req .__str__ ())
314+
315+
296316class MyVersion (Version ):
297317 def __init__ (self , domain ):
298318 super ().__init__ (domain , "v1" )
Original file line number Diff line number Diff line change @@ -56,10 +56,6 @@ def __eq__(self, other) -> bool:
5656 )
5757
5858 def __str__ (self ) -> str :
59- auth = ""
60- if self .auth and self .auth != Match .ANY :
61- auth = "{} " .format (self .auth )
62-
6359 params = ""
6460 if self .params and self .params != Match .ANY :
6561 params = "?{}" .format (urlencode (self .params , doseq = True ))
@@ -78,8 +74,7 @@ def __str__(self) -> str:
7874 "\n " .join (' -H "{}: {}"' .format (k , v ) for k , v in self .headers .items ())
7975 )
8076
81- return "{auth}{method} {url}{params}{data}{headers}" .format (
82- auth = auth ,
77+ return "{method} {url}{params}{data}{headers}" .format (
8378 method = self .method ,
8479 url = self .url ,
8580 params = params ,
You can’t perform that action at this time.
0 commit comments