From e1dfb7c8839553abae206bb55dfdf22dd5225f2d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 15 Oct 2011 09:55:00 -0400 Subject: [PATCH 1/3] httpbin --- reqs.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/reqs.txt b/reqs.txt index 43c7c061..14684e73 100644 --- a/reqs.txt +++ b/reqs.txt @@ -1,3 +1,4 @@ +httpbin nose pyflakes omnijson \ No newline at end of file From d98de70f4acfa93bcec4ae77ee04c57b9945a3b4 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 15 Oct 2011 11:05:29 -0400 Subject: [PATCH 2/3] envoy. --- reqs.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reqs.txt b/reqs.txt index 14684e73..1729ab7f 100644 --- a/reqs.txt +++ b/reqs.txt @@ -1,4 +1,5 @@ -httpbin +envoy==0.0.2 nose pyflakes -omnijson \ No newline at end of file +omnijson +httpbin \ No newline at end of file From 35bfa9e91d93c695f5cd421148a472e61da05a11 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 15 Oct 2011 11:55:57 -0400 Subject: [PATCH 3/3] HTTP Integration --- test_requests.py | 69 ++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/test_requests.py b/test_requests.py index 83b827ab..ff42a7a5 100755 --- a/test_requests.py +++ b/test_requests.py @@ -16,11 +16,7 @@ import requests from requests.sessions import Session -HTTPBIN_URL = 'http://httpbin.ep.io/' -HTTPSBIN_URL = 'https://httpbin.ep.io/' - -# HTTPBIN_URL = 'http://staging.httpbin.org/' -# HTTPSBIN_URL = 'https://httpbin-staging.ep.io/' +HTTPBIN_URL = 'http://127.0.0.1:44444/' def httpbin(*suffix): @@ -29,15 +25,9 @@ def httpbin(*suffix): return HTTPBIN_URL + '/'.join(suffix) -def httpsbin(*suffix): - """Returns url for HTTPSBIN resource.""" - - return HTTPSBIN_URL + '/'.join(suffix) - - -SERVICES = (httpbin, httpsbin) - +SERVICES = (httpbin, ) +_httpbin = False class RequestsTestSuite(unittest.TestCase): """Requests test cases.""" @@ -46,12 +36,25 @@ class RequestsTestSuite(unittest.TestCase): _multiprocess_can_split_ = True def setUp(self): - pass + + global _httpbin + + if not _httpbin: + import envoy + self.httpbin = envoy.connect('httpbin 44444') + # print self.httpbin + + _httpbin = True + # print '!'/ + + import time + time.sleep(1) + def tearDown(self): """Teardown.""" - pass + # self.httpbin.kill() def test_invalid_url(self): @@ -59,7 +62,7 @@ class RequestsTestSuite(unittest.TestCase): def test_HTTP_200_OK_GET(self): - r = requests.get(httpbin('/')) + r = requests.get(httpbin('/get')) self.assertEqual(r.status_code, 200) def test_HTTP_302_ALLOW_REDIRECT_GET(self): @@ -70,10 +73,6 @@ class RequestsTestSuite(unittest.TestCase): r = requests.get(httpbin('redirect', '1'), allow_redirects=False) self.assertEqual(r.status_code, 302) - def test_HTTPS_200_OK_GET(self): - r = requests.get(httpsbin('/')) - self.assertEqual(r.status_code, 200) - def test_HTTP_200_OK_GET_WITH_PARAMS(self): heads = {'User-agent': 'Mozilla/5.0'} @@ -112,12 +111,7 @@ class RequestsTestSuite(unittest.TestCase): def test_HTTP_200_OK_HEAD(self): - r = requests.head(httpbin('/')) - self.assertEqual(r.status_code, 200) - - - def test_HTTPS_200_OK_HEAD(self): - r = requests.head(httpsbin('/')) + r = requests.head(httpbin('/get')) self.assertEqual(r.status_code, 200) @@ -126,21 +120,11 @@ class RequestsTestSuite(unittest.TestCase): self.assertEqual(r.status_code, 200) - def test_HTTPS_200_OK_PUT(self): - r = requests.put(httpsbin('put')) - self.assertEqual(r.status_code, 200) - - def test_HTTP_200_OK_PATCH(self): r = requests.patch(httpbin('patch')) self.assertEqual(r.status_code, 200) - def test_HTTPS_200_OK_PATCH(self): - r = requests.patch(httpsbin('patch')) - self.assertEqual(r.status_code, 200) - - def test_AUTH_HTTP_200_OK_GET(self): for service in SERVICES: @@ -206,7 +190,7 @@ class RequestsTestSuite(unittest.TestCase): r = requests.get(service('status', '500')) self.assertEqual(bool(r), False) - r = requests.get(service('/')) + r = requests.get(service('/get')) self.assertEqual(bool(r), True) @@ -257,7 +241,7 @@ class RequestsTestSuite(unittest.TestCase): for service in SERVICES: - url = service('/') + url = service('/get') requests.get(url, params={'foo': u'føø'}) requests.get(url, params={u'føø': u'føø'}) @@ -470,14 +454,7 @@ class RequestsTestSuite(unittest.TestCase): def test_session_HTTP_200_OK_GET(self): s = Session() - r = s.get(httpbin('/')) - self.assertEqual(r.status_code, 200) - - - def test_session_HTTPS_200_OK_GET(self): - - s = Session() - r = s.get(httpsbin('/')) + r = s.get(httpbin('/get')) self.assertEqual(r.status_code, 200)