8000 Add test for proxy info · 42cc/twilio-python@d13d45e · GitHub
[go: up one dir, main page]

Skip to content

Commit d13d45e

Browse files
committed
Add test for proxy info
1 parent 1a2dbb5 commit d13d45e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/test_make_request.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
Uses the awesome httpbin.org to validate responses
55
"""
66
import twilio
7-
from nose.tools import raises
8-
from mock import patch, Mock
7+
from nose.tools import assert_equal, raises
8+
from mock import patch, Mock, ANY
99
from twilio import TwilioRestException
1010
from twilio.rest.resources.base import make_request, make_twilio_request
11+
from twilio.rest.resources.connection import Connection
1112

1213
get_headers = {
1314
"User-Agent": "twilio-python/%s" % (twilio.__version__),
@@ -90,3 +91,19 @@ def test_make_twilio_request_bad_data(mock):
9091
make_twilio_request("POST", url)
9192
mock.assert_called_with("POST", "http://random/url.json",
9293
headers=post_headers)
94+
95+
96+
@patch('twilio.rest.resources.base.Response')
97+
@patch('httplib2.Http')
98+
def test_proxy_info(http_mock, resp_mock):
99+
http = Mock()
100+
http.request.return_value = (Mock(), Mock())
101+
http_mock.return_value = http
102+
Connection.set_proxy_info('http://example.com/proxy', '8080')
103+
make_request("GET", "http://httpbin.org/get")
104+
http_mock.assert_called_with(timeout=None, ca_certs=ANY, proxy_info=ANY)
105+
http.request.assert_called_with("http://httpbin.org/get", "GET",
106+
body=None, headers=None)
107+
proxy_info = http_mock.call_args[1]['proxy_info']
108+
assert_equal(proxy_info.proxy_host, 'http://example.com/proxy')
109+
assert_equal(proxy_info.proxy_port, '8080')

0 commit comments

Comments
 (0)
0