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

Commit

Permalink
bug: capture ValueError for empty notifications arrays
Browse files Browse the repository at this point in the history
Empty pending notification arrays may be returned. Removing a value can
trigger a ValueError that can be safely ignored.

Closes #385
  • Loading branch information
jrconlin committed Mar 4, 2016
1 parent 86e0ab1 commit ce27f1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions autopush/tests/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,14 @@ def test_ack_remove_not_set(self):
self.proto.ps.updates_sent[chid] = None
self.proto._handle_webpush_update_remove(None, chid, notif)

def test_ack_remove_missing(self):
self._connect()
chid = str(uuid.uuid4())
notif = Notification(version="bleh", headers={}, data="meh",
channel_id=chid, ttl=200, timestamp=0)
self.proto.ps.updates_sent[chid] = []
self.proto._handle_webpush_update_remove(None, chid, notif)

def test_ack_fails_first_time(self):
self._connect()
self.proto.ps.uaid = str(uuid.uuid4())
Expand Down
2 changes: 1 addition & 1 deletion autopush/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ def _handle_webpush_update_remove(self, result, chid, notif):
"""
try:
self.ps.updates_sent[chid].remove(notif)
except AttributeError:
except (AttributeError, ValueError):
pass

def _handle_simple_ack(self, chid, version, code):
Expand Down

0 comments on commit ce27f1e

Please sign in to comment.