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

Commit

Permalink
fix: Normalize endpoint and web _router_completed calls and tests
Browse files Browse the repository at this point in the history
closes #549
  • Loading branch information
jrconlin committed Aug 2, 2016
1 parent d74c00c commit 53df3f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions autopush/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,11 @@ def _router_completed(self, response, uaid_data, warning=""):
# TODO: Add some custom wake logic here

# Were we told to update the router data?
if response.router_data:
uaid_data["router_data"] = response.router_data
if response.router_data is not None:
if not response.router_data:
del uaid_data["router_data"]
else:
uaid_data["router_data"] = response.router_data
uaid_data["connected_at"] = ms_time()
d = deferToThread(self.ap_settings.router.register_user,
uaid_data)
Expand Down
7 changes: 5 additions & 2 deletions autopush/tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,10 @@ def test_put_router_needs_change(self):
def handle_finish(result):
self.assertTrue(result)
self.endpoint.set_status.assert_called_with(500, None)
ok_(not self.router_mock.register_user.called)
ru = self.router_mock.register_user
ok_(ru.called)
eq_('simplepush', ru.call_args[0][0].get('router_type'))

self.finish_deferred.addCallback(handle_finish)

self.endpoint.put(None, dummy_uaid)
Expand All @@ -638,7 +641,7 @@ def test_put_router_needs_update(self):
)
self.sp_router_mock.route_notification.return_value = RouterResponse(
status_code=503,
router_data=dict(token="new_connect"),
router_data=dict(token="new_connect", router_type="simplepush"),
)

def handle_finish(result):
Expand Down

0 comments on commit 53df3f3

Please sign in to comment.