本文整理匯總了Python中autopush.db.Message.fetch_messages方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.fetch_messages方法的具體用法?Python Message.fetch_messages怎麽用?Python Message.fetch_messages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類autopush.db.Message
的用法示例。
在下文中一共展示了Message.fetch_messages方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_message_delete_pagination
# 需要導入模塊: from autopush.db import Message [as 別名]
# 或者: from autopush.db.Message import fetch_messages [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)
示例2: test_message_storage
# 需要導入模塊: from autopush.db import Message [as 別名]
# 或者: from autopush.db.Message import fetch_messages [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)
示例3: test_update_message
# 需要導入模塊: from autopush.db import Message [as 別名]
# 或者: from autopush.db.Message import fetch_messages [as 別名]
def test_update_message(self):
chid = uuid.uuid4().hex
m = get_rotating_message_table()
message = Message(m, SinkMetrics())
data1 = str(uuid.uuid4())
data2 = str(uuid.uuid4())
time1 = self._nstime()
time2 = self._nstime() + 100
ttl = self._nstime() + 1000
message.store_message(self.uaid, chid, time1, ttl, data1, {})
message.update_message(self.uaid, chid, time2, ttl, data2, {})
messages = list(message.fetch_messages(self.uaid))
eq_(data2, messages[0]["#dd"])