8000 Remove httpbin.org testing dependency · MC6/twilio-python@259abd7 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 259abd7

Browse files
committed
Remove httpbin.org testing dependency
1 parent ea04f03 commit 259abd7

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

tests/test_make_request.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,39 @@
2121
post_headers = get_headers.copy()
2222
post_headers["Content-Type"] = "application/x-www-form-urlencoded"
2323

24-
def test_get_params():
25-
tests = [
26-
("http://httpbin.org/get", {"hey":"you", "foo":"bar"}),
27-
("http://httpbin.org/get?hey=you", {"foo":"bar"}),
28-
("http://httpbin.org/get?hey=you&foo=bar", {}),
29-
]
30-
31-
for test in tests:
32-
yield check_get_params, test[0], test[1]
33-
34-
def check_get_params(url, params):
35-
resp = make_request("GET", url, params=params)
36-
body = json.loads(resp.content)
37-
38-
assert_equals(body["args"]["hey"], "you")
39-
assert_equals(body["args"]["foo"], "bar")
40-
41-
def test_resp_uri():
42-
resp = make_request("GET", "http://httpbin.org/get")
43-
assert_equals(resp.url, "http://httpbin.org/get")
24+
25+
@patch('twilio.rest.resources.Response')
26+
@patch('httplib2.Http')
27+
def test_get_params(http_mock, response_mock):
28+
http = Mock()
29+
http.request.return_value = (Mock(), Mock())
30+
http_mock.return_value = http
31+
make_request("GET", "http://httpbin.org/get", params={"hey": "you"})
32+
http.request.assert_called_with("http://httpbin.org/get?hey=you", "GET",
33+
body=None, headers=None)
34+
35+
36+
@patch('twilio.rest.resources.Response')
37+
@patch('httplib2.Http')
38+
def test_get_extra_paranms(http_mock, response_mock):
39+
http = Mock()
40+
http.request.return_value = (Mock(), Mock())
41+
http_mock.return_value = http
42+
make_request("GET", "http://httpbin.org/get?foo=bar", params={"hey": "you"})
43+
http.request.assert_called_with("http://httpbin.org/get?foo=bar&hey=you", "GET",
44+
body=None, headers=None)
45+
46+
47+
@patch('twilio.rest.resources.Response')
48+
@patch('httplib2.Http')
49+
def test_resp_uri(http_mock, response_mock):
50+
http = Mock()
51+
http.request.return_value = (Mock(), Mock())
52+
http_mock.return_value = http
53+
make_request("GET", "http://httpbin.org/get")
54+
http.request.assert_called_with("http://httpbin.org/get", "GET",
55+
body=None, headers=None)
56+
4457

4558
@patch('twilio.rest.resources.make_request')
4659
def test_make_twilio_request_headers(mock):

0 commit comments

Comments
 (0)
0