forked from twilio/twilio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_unicode.py
70 lines (49 loc) · 1.85 KB
/
test_unicode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
from mock import patch, Mock
from six import u
from twilio.rest import resources
@patch("httplib2.Http")
@patch("twilio.rest.resources.base.Response")
def test_ascii_encode(resp_mock, mock):
http = mock.return_value
http.request.return_value = (Mock(), Mock())
data = {
"body": "HeyHey".encode('utf-8')
}
resources.make_request("GET", "http://www.example.com", data=data)
http.request.assert_called_with("http://www.example.com", "GET",
headers=None, body="body=HeyHey")
@patch("httplib2.Http")
@patch("twilio.rest.resources.base.Response")
def test_ascii(resp_mock, mock):
http = mock.return_value
http.request.return_value = (Mock(), Mock())
data = {
"body": "HeyHey"
}
resources.make_request("GET", "http://www.example.com", data=data)
http.request.assert_called_with("http://www.example.com", "GET",
headers=None, body="body=HeyHey")
@patch("httplib2.Http")
@patch("twilio.rest.resources.base.Response")
def test_double_encoding(resp_mock, mock):
http = mock.return_value
http.request.return_value = (Mock(), Mock())
body = u('Chlo\xe9\xf1')
data = {
"body": body.encode('utf-8'),
}
resources.make_request("GET", "http://www.example.com", data=data)
http.request.assert_called_with("http://www.example.com", "GET",
headers=None, body="body=Chlo%C3%A9%C3%B1")
@patch("httplib2.Http")
@patch("twilio.rest.resources.base.Response")
def test_paging(resp_mock, mock):
http = mock.return_value
http.request.return_value = (Mock(), Mock())
data = {
"body": u('Chlo\xe9\xf1'),
}
resources.make_request("GET", "http://www.example.com", data=data)
http.request.assert_called_with("http://www.example.com", "GET",
headers=None, body="body=Chlo%C3%A9%C3%B1")