aboutsummaryrefslogtreecommitdiff
path: root/tests/test_requests_async.py
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:41:22 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:41:22 -0700
commit3a4ef8165fb2951781a7bcc4189e90faf26caf2d (patch)
tree5223d80835a57dad6b7b6e0c37f689441ccb4e1e /tests/test_requests_async.py
parent40337989ba5056432c9f2af3c42267e5ee9e3e18 (diff)
downloadpython-requests-3a4ef8165fb2951781a7bcc4189e90faf26caf2d.tar
python-requests-3a4ef8165fb2951781a7bcc4189e90faf26caf2d.tar.gz
Imported Upstream version 0.11.2
Diffstat (limited to 'tests/test_requests_async.py')
-rwxr-xr-xtests/test_requests_async.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/test_requests_async.py b/tests/test_requests_async.py
new file mode 100755
index 0000000..1d28261
--- /dev/null
+++ b/tests/test_requests_async.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Path hack.
+import sys, os
+sys.path.insert(0, os.path.abspath('..'))
+
+import sys
+import unittest
+
+import select
+has_poll = hasattr(select, "poll")
+
+from requests import async
+import envoy
+
+sys.path.append('.')
+from test_requests import httpbin, RequestsTestSuite, SERVICES
+
+
+class RequestsTestSuiteUsingAsyncApi(RequestsTestSuite):
+ """Requests async test cases."""
+
+ def patched(f):
+ """Automatically send request after creation."""
+
+ def wrapped(*args, **kwargs):
+
+ request = f(*args, **kwargs)
+ return async.map([request])[0]
+
+ return wrapped
+
+ # Patched requests.api functions.
+ global request
+ request = patched(async.request)
+
+ global delete, get, head, options, patch, post, put
+ delete = patched(async.delete)
+ get = patched(async.get)
+ head = patched(async.head)
+ options = patched(async.options)
+ patch = patched(async.patch)
+ post = patched(async.post)
+ put = patched(async.put)
+
+
+ def test_entry_points(self):
+
+ async.request
+
+ async.delete
+ async.get
+ async.head
+ async.options
+ async.patch
+ async.post
+ async.put
+
+ async.map
+ async.send
+
+ def test_select_poll(self):
+ """Test to make sure we don't overwrite the poll"""
+ self.assertEqual(hasattr(select, "poll"), has_poll)
+
+if __name__ == '__main__':
+ unittest.main()