本文整理汇总了Python中autopush.db.Message.register_channel方法的典型用法代码示例。如果您正苦于以下问题:Python Message.register_channel方法的具体用法?Python Message.register_channel怎么用?Python Message.register_channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopush.db.Message
的用法示例。
在下文中一共展示了Message.register_channel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_message_storage
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_message_storage(self):
chid = str(uuid.uuid4())
chid2 = str(uuid.uuid4())
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
message.register_channel(self.uaid, chid2)
data1 = str(uuid.uuid4())
data2 = str(uuid.uuid4())
ttl = int(time.time()) + 100
time1, time2, time3 = self._nstime(), self._nstime(), self._nstime() + 1
message.store_message(self.uaid, chid, time1, ttl, data1, {})
message.store_message(self.uaid, chid2, time2, ttl, data2, {})
message.store_message(self.uaid, chid2, time3, ttl, data1, {})
all_messages = list(message.fetch_messages(self.uaid))
eq_(len(all_messages), 3)
message.delete_messages_for_channel(self.uaid, chid2)
all_messages = list(message.fetch_messages(self.uaid))
eq_(len(all_messages), 1)
message.delete_message(self.uaid, chid, time1)
all_messages = list(message.fetch_messages(self.uaid))
eq_(len(all_messages), 0)
示例2: test_message_delete_pagination
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_message_delete_pagination(self):
def make_messages(channel_id, count):
m = []
t = self._nstime()
ttl = int(time.time()) + 200
for i in range(count):
m.append((self.uaid, channel_id, str(uuid.uuid4()), ttl, {}, t + i))
return m
chid = str(uuid.uuid4())
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
# Shove 80 messages in
for message_args in make_messages(chid, 80):
message.store_message(*message_args)
# Verify we can see them all
all_messages = list(message.fetch_messages(self.uaid, limit=100))
eq_(len(all_messages), 80)
# Delete them all
message.delete_messages_for_channel(self.uaid, chid)
# Verify they're gone
all_messages = list(message.fetch_messages(self.uaid, limit=100))
eq_(len(all_messages), 0)
示例3: test_unregister
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_unregister(self):
chid = str(uuid.uuid4())
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
# Verify its in the db
rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
results = list(rows)
assert len(results) == 1
eq_(results[0]["chids"], set([chid]))
message.unregister_channel(self.uaid, chid)
# Verify its not in the db
rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
results = list(rows)
assert len(results) == 1
eq_(results[0]["chids"], set([]))
# Test for the very unlikely case that there's no 'chid'
m.connection.update_item = Mock()
m.connection.update_item.return_value = {"Attributes": {"uaid": {"S": self.uaid}}, "ConsumedCapacityUnits": 0.5}
r = message.unregister_channel(self.uaid, "test")
eq_(r, False)
示例4: test_register
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_register(self):
chid = str(uuid.uuid4())
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
# Verify its in the db
rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
results = list(rows)
assert len(results) == 1
示例5: test_save_channels
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_save_channels(self):
chid = str(uuid.uuid4())
chid2 = str(uuid.uuid4())
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
message.register_channel(self.uaid, chid2)
exists, chans = message.all_channels(self.uaid)
new_uaid = uuid.uuid4().hex
message.save_channels(new_uaid, chans)
_, new_chans = message.all_channels(new_uaid)
eq_(chans, new_chans)
示例6: test_all_channels
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_all_channels(self):
chid = str(uuid.uuid4())
chid2 = str(uuid.uuid4())
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
message.register_channel(self.uaid, chid2)
_, chans = message.all_channels(self.uaid)
assert chid in chans
assert chid2 in chans
message.unregister_channel(self.uaid, chid2)
_, chans = message.all_channels(self.uaid)
assert chid2 not in chans
assert chid in chans
示例7: test_unregister
# 需要导入模块: from autopush.db import Message [as 别名]
# 或者: from autopush.db.Message import register_channel [as 别名]
def test_unregister(self):
chid = str(uuid.uuid4())
m = get_message_table()
message = Message(m, SinkMetrics())
message.register_channel(self.uaid, chid)
# Verify its in the db
rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
results = list(rows)
assert(len(results) == 1)
eq_(results[0]["chids"], set([chid]))
message.unregister_channel(self.uaid, chid)
# Verify its not in the db
rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
results = list(rows)
assert(len(results) == 1)
eq_(results[0]["chids"], set([]))