Skip to content

Commit 1964469

Browse files
chore: remove auth from request.__str__()
1 parent 50a271c commit 1964469

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

tests/unit/http/test_http_client.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from twilio.base.version import Version
1111
from twilio.http.http_client import TwilioHttpClient
1212
from twilio.http.response import Response
13+
from twilio.http.request import Request
1314

1415

1516
class 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+
296316
class MyVersion(Version):
297317
def __init__(self, domain):
298318
super().__init__(domain, "v1")

twilio/http/request.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)