本文整理汇总了Python中autopush.db.Router.clear_node方法的典型用法代码示例。如果您正苦于以下问题:Python Router.clear_node方法的具体用法?Python Router.clear_node怎么用?Python Router.clear_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopush.db.Router
的用法示例。
在下文中一共展示了Router.clear_node方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clear_node_provision_failed
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import clear_node [as 别名]
def test_clear_node_provision_failed(self):
r = get_router_table()
router = Router(r, SinkMetrics())
router.table.connection.put_item = Mock()
def raise_error(*args, **kwargs):
raise ProvisionedThroughputExceededException(None, None)
router.table.connection.put_item.side_effect = raise_error
with self.assertRaises(ProvisionedThroughputExceededException):
router.clear_node(Item(r, dict(uaid="asdf", connected_at="1234", node_id="asdf")))
示例2: test_node_clear
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import clear_node [as 别名]
def test_node_clear(self):
r = get_router_table()
router = Router(r, SinkMetrics())
# Register a node user
router.register_user(dict(uaid="asdf", node_id="asdf", connected_at=1234))
# Verify
user = router.get_uaid("asdf")
eq_(user["node_id"], "asdf")
# Clear
router.clear_node(user)
# Verify
user = router.get_uaid("asdf")
eq_(user.get("node_id"), None)
示例3: test_node_clear_fail
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import clear_node [as 别名]
def test_node_clear_fail(self):
r = get_router_table()
router = Router(r, SinkMetrics())
def raise_condition(*args, **kwargs):
raise ConditionalCheckFailedException(None, None)
router.table.connection.put_item = Mock()
router.table.connection.put_item.side_effect = raise_condition
data = dict(uaid="asdf", node_id="asdf", connected_at=1234)
result = router.clear_node(Item(r, data))
eq_(result, False)
示例4: test_preflight_check_fail
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import clear_node [as 别名]
def test_preflight_check_fail(self):
router = Router(get_router_table(), SinkMetrics())
storage = Storage(get_storage_table(), SinkMetrics())
def raise_exc(*args, **kwargs): # pragma: no cover
raise Exception("Oops")
router.clear_node = Mock()
router.clear_node.side_effect = raise_exc
with self.assertRaises(Exception):
preflight_check(storage, router)
示例5: test_node_clear
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import clear_node [as 别名]
def test_node_clear(self):
r = get_router_table()
router = Router(r, SinkMetrics())
# Register a node user
router.register_user(dict(uaid=dummy_uaid, node_id="asdf",
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)
# Verify
user = router.get_uaid(dummy_uaid)
eq_(user.get("node_id"), None)
eq_(user["connected_at"], 1234)
eq_(user["router_key"], "webpush")