Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:mozilla-services/autopush into fe…
Browse files Browse the repository at this point in the history
…at/655
  • Loading branch information
jrconlin committed Sep 16, 2016
2 parents 752ce54 + b1a7e2d commit 7cd5d6e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
8 changes: 4 additions & 4 deletions autopush/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ def post(self, router_type="", router_token="", uaid="", chid=""):
self.app_server_key = params.get("key")
if new_uaid:
d = Deferred()
d.addCallback(router.register, params, app_id=router_token,
uri=self.request.uri)
d.addCallback(router.register, router_data=params,
app_id=router_token, uri=self.request.uri)
d.addCallback(self._save_router_data, router_type)
d.addCallback(self._create_endpoint)
d.addCallback(self._return_endpoint, new_uaid, router)
Expand Down Expand Up @@ -742,8 +742,8 @@ def put(self, router_type="", router_token="", uaid="", chid=""):

self.add_header("Content-Type", "application/json")
d = Deferred()
d.addCallback(router.register, router_data, app_id=router_token,
uri=self.request.uri)
d.addCallback(router.register, router_data=router_data,
app_id=router_token, uri=self.request.uri)
d.addCallback(self._save_router_data, router_type)
d.addCallback(self._success)
d.addErrback(self._router_fail_err)
Expand Down
2 changes: 1 addition & 1 deletion autopush/router/gcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def register(self, uaid, router_data, app_id, *args, **kwargs):
if senderid not in self.senderIDs:
raise self._error("Invalid SenderID", status=410, errno=105,
uri=kwargs.get('uri'),
senderid=repr(senderid))
senderid=senderid)
# Assign a senderid
router_data["creds"] = {"senderID": senderid,
"auth": self.senderIDs[senderid]}
Expand Down
2 changes: 1 addition & 1 deletion autopush/router/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, ap_settings, router_conf):
self.conf = router_conf
self.waker = None

def register(self, uaid, connect, *args, **kwargs):
def register(self, uaid, *args, **kwargs):
"""Return no additional routing data"""
return {}

Expand Down
5 changes: 4 additions & 1 deletion autopush/tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,10 @@ def test_put(self, *args):
def handle_finish(value):
self.reg.write.assert_called_with({})
frouter.register.assert_called_with(
dummy_uaid, data, app_id="", uri=self.reg.request.uri
dummy_uaid,
app_id='',
router_data=data,
uri=self.reg.request.uri
)

self.finish_deferred.addCallback(handle_finish)
Expand Down
33 changes: 19 additions & 14 deletions autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from twisted.trial import unittest
from twisted.internet.error import ConnectError, ConnectionRefusedError
from twisted.python.failure import Failure
from twisted.internet import reactor

import apns
import gcmclient
Expand Down Expand Up @@ -117,17 +116,20 @@ def test_with_max(self, cl):
ok_('max_messages' not in self.router._config)

def test_register(self):
result = self.router.register("uaid", {"token": "connect_data"},
"firefox")
result = self.router.register("uaid",
router_data={"token": "connect_data"},
app_id="firefox")
eq_(result, {"rel_channel": "firefox", "token": "connect_data"})

def test_register_bad(self):
self.assertRaises(RouterException, self.router.register,
"uaid", {}, "firefox")
"uaid", router_data={}, app_id="firefox")

def test_register_bad_channel(self):
self.assertRaises(RouterException, self.router.register,
"uaid", {"token": "connect_data"}, "unknown")
"uaid",
router_data={"token": "connect_data"},
app_id="unknown")

def test_route_notification(self):
d = self.router.route_notification(self.notif, self.router_data)
Expand Down Expand Up @@ -319,7 +321,7 @@ def test_init(self):
{"senderIDs": {}})

def test_register(self):
result = self.router.register(uaid="uaid",
result = self.router.register("uaid",
router_data={"token": "test123"},
app_id="test123")
# Check the information that will be recorded for this user
Expand All @@ -328,13 +330,15 @@ def test_register(self):
"auth": "12345678abcdefg"}})

def test_register_bad(self):
self.assertRaises(RouterException, self.router.register,
"uaid", {}, "")
self.assertRaises(RouterException,
self.router.register,
"uaid",
{"token": "abcd1234"},
"invalid123")
router_data={},
app_id="")
self.assertRaises(RouterException,
self.router.register, "uaid",
router_data={"token": "abcd1234"},
reg_id="invalid123")

@patch("gcmclient.GCM")
def test_gcmclient_fail(self, fgcm):
Expand Down Expand Up @@ -518,7 +522,7 @@ def check_results(fail):
return d

def test_amend(self):
self.router.register(uaid="uaid",
self.router.register("uaid",
router_data={"token": "test123"},
app_id="test123")
resp = {"key": "value"}
Expand Down Expand Up @@ -588,7 +592,7 @@ def throw_auth(*args, **kwargs):
self.assertRaises(IOError, FCMRouter, settings, {})

def test_register(self):
result = self.router.register(uaid="uaid",
result = self.router.register("uaid",
router_data={"token": "test123"},
app_id="test123")
# Check the information that will be recorded for this user
Expand All @@ -597,7 +601,8 @@ def test_register(self):
"auth": "12345678abcdefg"}})

def test_register_bad(self):
self.assertRaises(RouterException, self.router.register, "uaid", {})
self.assertRaises(RouterException, self.router.register, "uaid",
router_data={})

def test_route_notification(self):
self.router.fcm = self.fcm
Expand Down Expand Up @@ -816,7 +821,7 @@ def _raise_item_error(self):
raise ItemNotFound()

def test_register(self):
r = self.router.register(None, {})
r = self.router.register("uaid", router_data={})
eq_(r, {})

def test_route_to_connected(self):
Expand Down

0 comments on commit 7cd5d6e

Please sign in to comment.