本文整理汇总了Python中autopush.db.Router.register_user方法的典型用法代码示例。如果您正苦于以下问题:Python Router.register_user方法的具体用法?Python Router.register_user怎么用?Python Router.register_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopush.db.Router
的用法示例。
在下文中一共展示了Router.register_user方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_drop_user
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_drop_user(self):
uaid = str(uuid.uuid4())
r = get_router_table()
router = Router(r, SinkMetrics())
# Register a node user
router.register_user(dict(uaid=uaid, node_id="asdf",
connected_at=1234))
router.drop_user(uaid)
示例2: test_incomplete_uaid
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_incomplete_uaid(self):
uaid = str(uuid.uuid4())
r = get_router_table()
router = Router(r, SinkMetrics())
router.register_user(dict(uaid=uaid))
self.assertRaises(ItemNotFound, router.get_uaid, uaid)
self.assertRaises(ItemNotFound, router.table.get_item,
consistent=True, uaid=uaid)
示例3: test_drop_user
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_drop_user(self):
uaid = str(uuid.uuid4())
r = get_router_table()
router = Router(r, SinkMetrics())
# Register a node user
router.register_user(dict(uaid=uaid, node_id="asdf", connected_at=1234))
result = router.drop_user(uaid)
eq_(result, True)
# Deleting already deleted record should return false.
result = router.drop_user(uaid)
eq_(result, False)
示例4: test_register_user_provision_failed
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_register_user_provision_failed(self):
r = get_router_table()
router = Router(r, SinkMetrics())
router.table.connection = Mock()
def raise_error(*args, **kwargs):
raise ProvisionedThroughputExceededException(None, None)
router.table.connection.update_item.side_effect = raise_error
with self.assertRaises(ProvisionedThroughputExceededException):
router.register_user(dict(uaid="asdf", node_id="me", connected_at=1234))
示例5: test_node_clear
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [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)
示例6: test_save_new
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_save_new(self):
r = get_router_table()
router = Router(r, SinkMetrics())
# Sadly, moto currently does not return an empty value like boto
# when not updating data.
router.table.connection = Mock()
router.table.connection.update_item.return_value = {}
result = router.register_user(dict(uaid="", node_id="me", connected_at=1234))
eq_(result[0], True)
示例7: test_save_uaid
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_save_uaid(self):
uaid = str(uuid.uuid4())
r = get_router_table()
router = Router(r, SinkMetrics())
result = router.register_user(dict(uaid=uaid, node_id="me", connected_at=1234))
eq_(result[0], True)
eq_(result[1], {"uaid": uaid, "connected_at": 1234, "node_id": "me"})
result = router.get_uaid(uaid)
eq_(bool(result), True)
eq_(result["node_id"], "me")
示例8: test_save_fail
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [as 别名]
def test_save_fail(self):
r = get_router_table()
router = Router(r, SinkMetrics())
def raise_condition(*args, **kwargs):
raise ConditionalCheckFailedException(None, None)
router.table.connection = Mock()
router.table.connection.update_item.side_effect = raise_condition
router_data = dict(uaid="asdf", node_id="asdf", connected_at=1234)
result = router.register_user(router_data)
eq_(result, (False, {}, router_data))
示例9: test_node_clear
# 需要导入模块: from autopush.db import Router [as 别名]
# 或者: from autopush.db.Router import register_user [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")