Skip to content

Commit f53c137

Browse files
committed
Merge pull request #57 from pusher/resolve-gae-issues
Made amendments to urlfetch backend. Addresses #54
2 parents 0895b61 + 8e13928 commit f53c137

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ language: python
33
python:
44
- "2.6"
55
- "2.7"
6-
# - "3.2"
76
- "3.3"
87
install:
98
- "python setup.py develop"

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: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,31 @@
55
import pusher
66
import httpretty
77
import sys
8+
import os
89

910
if (sys.version_info < (2,7)):
1011
import unittest2 as unittest
1112
else:
1213
import unittest
1314

14-
@unittest.skipIf(sys.version_info >= (3,), "skip")
15-
class TestURLFetchBackend(unittest.TestCase):
15+
skip_test = (sys.version_info[0:2] != (2,7)) or os.environ.get("TRAVIS_PYTHON_VERSION")
16+
17+
@unittest.skipIf(skip_test, "skip")
18+
class TestGAEBackend(unittest.TestCase):
1619

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

2231
@httpretty.activate
23-
def test_trigger_urlfetch_success(self):
32+
def test_trigger_gae_success(self):
2433
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
2534
body="{}",
2635
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)