Skip to content

Commit a38a340

Browse files
committed
Made amendments to urlfetch backend. Addresses #54
1 parent ff469db commit a38a340

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,13 @@ Users can configure the library to use different backends to send calls to our A
289289
* [Requests](http://docs.python-requests.org/en/latest/) (`pusher.requests.RequestsBackend`). This is used by default.
290290
* [Tornado](http://www.tornadoweb.org/en/stable/) (`pusher.tornado.TornadoBackend`).
291291
* [AsyncIO](http://asyncio.org/) (`pusher.aiohttp.AsyncIOBackend`).
292-
* [URLFetch](https://pypi.python.org/pypi/urlfetch) (`pusher.urlfetch.URLFetchBackend`).
292+
* [Google App Engine](https://cloud.google.com/appengine/docs/python/urlfetch/) (`pusher.gae.GAEBackend`).
293293

294294
Upon initializing a Pusher instance, pass in any of these options to the `backend` keyword argument.
295295

296296
### Google App Engine
297297

298-
GAE users are advised to use the URLFetch backend to ensure compatability.
298+
GAE users are advised to use the `pusher.gae.GAEBackend` backend to ensure compatability.
299299

300300
## Feature Support
301301

pusher/urlfetch.py renamed to pusher/gae.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from __future__ import (print_function, unicode_literals, absolute_import,
44
division)
55

6-
import urlfetch
6+
from google.appengine.api import urlfetch
77
from pusher.http import process_response
88

9-
class URLFetchBackend(object):
9+
class GAEBackend(object):
1010
"""Adapter for the URLFetch Module. Necessary for using this library with Google
1111
App Engine"""
1212

@@ -19,7 +19,7 @@ def send_request(self, request):
1919
url=request.url,
2020
headers=request.headers,
2121
method=request.method,
22-
data=request.body,
22+
payload=request.body,
2323
deadline=self.config.timeout,
2424
**self.options
2525
)

pusher_tests/test_urlfetch_adapter.py renamed to pusher_tests/test_gae_adapter.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@
1212
import unittest
1313

1414
@unittest.skipIf(sys.version_info >= (3,), "skip")
15-
class TestURLFetchBackend(unittest.TestCase):
15+
class TestGAEBackend(unittest.TestCase):
1616

1717
def setUp(self):
18-
import pusher.urlfetch
18+
import pusher.gae
19+
from google.appengine.api import apiproxy_stub_map, urlfetch_stub
20+
21+
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
22+
apiproxy_stub_map.apiproxy.RegisterStub('urlfetch',
23+
urlfetch_stub.URLFetchServiceStub())
24+
1925
self.p = pusher.Pusher.from_url(u'http://key:secret@api.pusherapp.com/apps/4',
20-
backend=pusher.urlfetch.URLFetchBackend)
26+
backend=pusher.gae.GAEBackend)
2127

2228
@httpretty.activate
23-
def test_trigger_urlfetch_success(self):
29+
def test_trigger_gae_success(self):
2430
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
2531
body="{}",
2632
content_type="application/json")

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
extras_require={
2828
'aiohttp': ["aiohttp>=0.9.0"],
29-
'tornado': ['tornado>=4.0.0'],
30-
'urlfetch': ['urlfetch>=1.0']
29+
'tornado': ['tornado>=4.0.0']
3130
},
3231

3332
test_suite='pusher_tests',

0 commit comments

Comments
 (0)