From d3cdee30c7203ef0cefa4003d55d4298c394c9d8 Mon Sep 17 00:00:00 2001 From: Ben Bangert Date: Fri, 11 Mar 2016 15:09:58 -0800 Subject: [PATCH] fix: clear only the node_id in the router record Closes #401 --- autopush/db.py | 2 +- autopush/tests/test_db.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/autopush/db.py b/autopush/db.py index c0ede2a4..2481b2a6 100644 --- a/autopush/db.py +++ b/autopush/db.py @@ -671,7 +671,7 @@ def clear_node(self, item): cond = "(node_id = :node) and (connected_at = :conn)" conn.put_item( self.table.table_name, - item=item.get_raw_keys(), + item=self.encode(item), condition_expression=cond, expression_attribute_values=self.encode({ ":node": node_id, diff --git a/autopush/tests/test_db.py b/autopush/tests/test_db.py index 1cb74104..e7399d30 100644 --- a/autopush/tests/test_db.py +++ b/autopush/tests/test_db.py @@ -478,11 +478,14 @@ def test_node_clear(self): # Register a node user router.register_user(dict(uaid=dummy_uaid, node_id="asdf", - connected_at=1234)) + connected_at=1234, + router_key="webpush")) # Verify user = router.get_uaid(dummy_uaid) eq_(user["node_id"], "asdf") + eq_(user["connected_at"], 1234) + eq_(user["router_key"], "webpush") # Clear router.clear_node(user) @@ -490,6 +493,8 @@ def test_node_clear(self): # Verify user = router.get_uaid(dummy_uaid) eq_(user.get("node_id"), None) + eq_(user["connected_at"], 1234) + eq_(user["router_key"], "webpush") def test_node_clear_fail(self): r = get_router_table()