Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for GAE's set_default_fetch_deadline function #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion python2/httplib2test_appengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@
dev_appserver.fix_sys_path()

from google.appengine.ext import testbed
from google.appengine.api.urlfetch import set_default_fetch_deadline

# Ensure that we are not loading the httplib2 version included in the Google
# App Engine SDK.
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))

# Ensure that httplib2 will use the patched httplib version later
if sys.version_info >= (2, 7):
import google.appengine.dist27.httplib
sys.modules["httplib"] = google.appengine.dist27.httplib
else:
import google.appengine.dist.httplib
sys.modules["httplib"] = google.appengine.dist.httplib
import httplib


class AberrationsTest(unittest.TestCase):

Expand Down Expand Up @@ -65,10 +75,16 @@ def testGet(self):
response, content = http.request("http://www.google.com")
self.assertEqual(httplib2.SCHEME_TO_CONNECTION['https'],
httplib2.AppEngineHttpsConnection)
self.assertEquals(1, len(http.connections))
self.assertTrue(2 >= len(http.connections))
self.assertEquals(response.status, 200)
self.assertEquals(response['status'], '200')

def testTimeout(self):
with self.assertRaises(httplib.HTTPException):
set_default_fetch_deadline(1)
http = httplib2.Http()
response, content = http.request("http://httpbin.org/delay/2")

def testProxyInfoIgnored(self):
http = httplib2.Http(proxy_info=mock.MagicMock())
response, content = http.request("http://www.google.com")
Expand Down