Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: python
python:
- "2.6"
- "2.7"
# - "3.2"
- "3.3"
install:
- "python setup.py develop"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ Users can configure the library to use different backends to send calls to our A
* [Requests](http://docs.python-requests.org/en/latest/) (`pusher.requests.RequestsBackend`). This is used by default.
* [Tornado](http://www.tornadoweb.org/en/stable/) (`pusher.tornado.TornadoBackend`).
* [AsyncIO](http://asyncio.org/) (`pusher.aiohttp.AsyncIOBackend`).
* [URLFetch](https://pypi.python.org/pypi/urlfetch) (`pusher.urlfetch.URLFetchBackend`).
* [Google App Engine](https://cloud.google.com/appengine/docs/python/urlfetch/) (`pusher.gae.GAEBackend`).

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

### Google App Engine

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

## Feature Support

Expand Down
6 changes: 3 additions & 3 deletions pusher/urlfetch.py → pusher/gae.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from __future__ import (print_function, unicode_literals, absolute_import,
division)

import urlfetch
from google.appengine.api import urlfetch
from pusher.http import process_response

class URLFetchBackend(object):
class GAEBackend(object):
"""Adapter for the URLFetch Module. Necessary for using this library with Google
App Engine"""

Expand All @@ -19,7 +19,7 @@ def send_request(self, request):
url=request.url,
headers=request.headers,
method=request.method,
data=request.body,
payload=request.body,
deadline=self.config.timeout,
**self.options
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@
import pusher
import httpretty
import sys
import os

if (sys.version_info < (2,7)):
import unittest2 as unittest
else:
import unittest

@unittest.skipIf(sys.version_info >= (3,), "skip")
class TestURLFetchBackend(unittest.TestCase):
skip_test = (sys.version_info[0:2] != (2,7)) or os.environ.get("TRAVIS_PYTHON_VERSION")

@unittest.skipIf(skip_test, "skip")
class TestGAEBackend(unittest.TestCase):

def setUp(self):
import pusher.urlfetch
import pusher.gae
from google.appengine.api import apiproxy_stub_map, urlfetch_stub

apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
apiproxy_stub_map.apiproxy.RegisterStub('urlfetch',
urlfetch_stub.URLFetchServiceStub())

self.p = pusher.Pusher.from_url(u'http://key:secret@api.pusherapp.com/apps/4',
backend=pusher.urlfetch.URLFetchBackend)
backend=pusher.gae.GAEBackend)

@httpretty.activate
def test_trigger_urlfetch_success(self):
def test_trigger_gae_success(self):
httpretty.register_uri(httpretty.POST, "http://api.pusherapp.com/apps/4/events",
body="{}",
content_type="application/json")
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

extras_require={
'aiohttp': ["aiohttp>=0.9.0"],
'tornado': ['tornado>=4.0.0'],
'urlfetch': ['urlfetch>=1.0']
'tornado': ['tornado>=4.0.0']
},

test_suite='pusher_tests',
Expand Down