8000 Allow unicode characters in SMS bodies · jseims/twilio-python@3fd9326 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fd9326

Browse files
committed
Allow unicode characters in SMS bodies
1 parent 2cc282f commit 3fd9326

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

tests/test_unicode.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
from mock import patch, Mock
3+
from twilio.rest import resources
4+
5+
@patch("httplib2.Http")
6+
@patch("twilio.rest.resources.Response")
7+
def test_paging(resp_mock, mock):
8+
http = mock.return_value
9+
http.request.return_value = (Mock(), Mock())
10+
11+
data = {
12+
"body": u"Chloéñ",
13+
}
14+
15+
resources.make_request("GET", "http://www.example.com", data=data)
16+
17+
http.request.assert_called_with("http://www.example.com", "GET",
18+
headers=None, body="body=Chlo%C3%A9%C3%B1")
19+
20+
21+

twilio/rest/resources.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ def make_request(method, url,
125125
http.add_credentials(auth[0], auth[1])
126126

127127
if data is not None:
128-
data = urlencode(data)
128+
udata = {}
129+
for k, v in data.iteritems():
130+
udata[k.encode('utf-8')] = unicode(v).encode('utf-8')
131+
data = urlencode(udata)
129132

130133
if params is not None:
131134
enc_params = urlencode(params, doseq=True)

0 commit comments

Comments
 (0)
0