Skip to content
Myr

Merge branch 'feature/httpbin' into develop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 15755be, 35bfa9e · Browse files · 2 files+26 added−47 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−47 removed

  • other:+26 added−47 removed

2 files+26 added−47 removed

modified:reqs.txt+3 added-1 removed
1envoy==0.0.22nose3pyflakes3omnijson4omnijson5httpbin
modified:test_requests.py+23 added-46 removed
14 unmodified lines
1516from requests.sessions import Session171819HTTPBIN_URL = 'http://httpbin.ep.io/'20HTTPSBIN_URL = 'https://httpbin.ep.io/'19HTTPBIN_URL = 'http://127.0.0.1:44444/'2022# HTTPBIN_URL = 'http://staging.httpbin.org/'23# HTTPSBIN_URL = 'https://httpbin-staging.ep.io/'212522def httpbin(*suffix):23 """Returns url for HTTPBIN resource."""2425 return HTTPBIN_URL + '/'.join(suffix)262732def httpsbin(*suffix):33 """Returns url for HTTPSBIN resource."""28SERVICES = (httpbin, )2935 return HTTPSBIN_URL + '/'.join(suffix)30_httpbin = False313738SERVICES = (httpbin, httpsbin)39404132class RequestsTestSuite(unittest.TestCase):33 """Requests test cases."""3435 # It goes to eleven.36 _multiprocess_can_split_ = True3738 def setUp(self):49 pass3940 global _httpbin4142 if not _httpbin:43 import envoy44 self.httpbin = envoy.connect('httpbin 44444')45 # print self.httpbin4647 _httpbin = True48 # print '!'/4950 import time51 time.sleep(1)52535455 def tearDown(self):56 """Teardown."""54 pass57 # self.httpbin.kill()585960 def test_invalid_url(self):61 self.assertRaises(ValueError, requests.get, 'hiwpefhipowhefopw')626364 def test_HTTP_200_OK_GET(self):62 r = requests.get(httpbin('/'))65 r = requests.get(httpbin('/get'))66 self.assertEqual(r.status_code, 200)6768 def test_HTTP_302_ALLOW_REDIRECT_GET(self):69 r = requests.get(httpbin('redirect', '1'))
2 unmodified lines
72 def test_HTTP_302_GET(self):73 r = requests.get(httpbin('redirect', '1'), allow_redirects=False)74 self.assertEqual(r.status_code, 302)7573 def test_HTTPS_200_OK_GET(self):74 r = requests.get(httpsbin('/'))75 self.assertEqual(r.status_code, 200)767777 def test_HTTP_200_OK_GET_WITH_PARAMS(self):78 heads = {'User-agent': 'Mozilla/5.0'}7980 r = requests.get(httpbin('user-agent'), headers=heads)
29 unmodified lines
110 self.assertTrue(heads['user-agent'] in r.content)111112113 def test_HTTP_200_OK_HEAD(self):115 r = requests.head(httpbin('/'))114 r = requests.head(httpbin('/get'))115 self.assertEqual(r.status_code, 200)116117119 def test_HTTPS_200_OK_HEAD(self):120 r = requests.head(httpsbin('/'))121 self.assertEqual(r.status_code, 200)122123118 def test_HTTP_200_OK_PUT(self):119 r = requests.put(httpbin('put'))120 self.assertEqual(r.status_code, 200)121122129 def test_HTTPS_200_OK_PUT(self):130 r = requests.put(httpsbin('put'))131 self.assertEqual(r.status_code, 200)132133123 def test_HTTP_200_OK_PATCH(self):124 r = requests.patch(httpbin('patch'))125 self.assertEqual(r.status_code, 200)126127139 def test_HTTPS_200_OK_PATCH(self):140 r = requests.patch(httpsbin('patch'))141 self.assertEqual(r.status_code, 200)142143128 def test_AUTH_HTTP_200_OK_GET(self):129130 for service in SERVICES:131
57 unmodified lines
189190 r = requests.get(service('status', '500'))191 self.assertEqual(bool(r), False)192209 r = requests.get(service('/'))193 r = requests.get(service('/get'))194 self.assertEqual(bool(r), True)195196197 def test_request_ok_set(self):
42 unmodified lines
240 def test_unicode_get(self):241242 for service in SERVICES:243260 url = service('/')244 url = service('/get')245246 requests.get(url, params={'foo': u'føø'})247 requests.get(url, params={u'føø': u'føø'})248 requests.get(url, params={'føø': 'føø'})
204 unmodified lines
453454 def test_session_HTTP_200_OK_GET(self):455456 s = Session()473 r = s.get(httpbin('/'))457 r = s.get(httpbin('/get'))458 self.assertEqual(r.status_code, 200)459460477 def test_session_HTTPS_200_OK_GET(self):478479 s = Session()480 r = s.get(httpsbin('/'))481 self.assertEqual(r.status_code, 200)482483461 def test_session_persistent_headers(self):462463 heads = {'User-agent': 'Mozilla/5.0'}464
14 unmodified lines