本文整理汇总了Python中the_tale.accounts.personal_messages.prototypes.MessagePrototype.remove_old_messages方法的典型用法代码示例。如果您正苦于以下问题:Python MessagePrototype.remove_old_messages方法的具体用法?Python MessagePrototype.remove_old_messages怎么用?Python MessagePrototype.remove_old_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.accounts.personal_messages.prototypes.MessagePrototype
的用法示例。
在下文中一共展示了MessagePrototype.remove_old_messages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_old_messages__hiden_by_recipients
# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import remove_old_messages [as 别名]
def test_remove_old_messages__hiden_by_recipients(self):
message_3 = MessagePrototype.create(self.account1, self.account2, 'message 3')
MessagePrototype.create(self.account1, self.account2, 'message 3')
self.message.hide_from(sender=True)
self.message_2.hide_from(recipient=True)
message_3.hide_from(sender=True, recipient=True)
with self.check_delta(MessagePrototype._db_count, -1):
MessagePrototype.remove_old_messages()
self.assertEqual(MessagePrototype.get_by_id(message_3.id), None)
示例2: test_remove_old_messages__system_user
# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import remove_old_messages [as 别名]
def test_remove_old_messages__system_user(self):
system_user = get_system_user()
messages = [ MessagePrototype.create(self.account1, self.account2, 'message 1'),
MessagePrototype.create(system_user, self.account2, 'message 2'),
MessagePrototype.create(self.account1, system_user, 'message 3'),
MessagePrototype.create(system_user, system_user, 'message 4'),
MessagePrototype.create(self.account1, self.account2, 'message 5'),
MessagePrototype.create(system_user, self.account2, 'message 6'),
MessagePrototype.create(self.account1, system_user, 'message 7'),
MessagePrototype.create(system_user, system_user, 'message 8') ]
for message in messages[-4:]:
message._model.created_at = datetime.datetime.now() - conf.settings.SYSTEM_MESSAGES_LEAVE_TIME
message.save()
with self.check_delta(MessagePrototype._db_count, -3):
MessagePrototype.remove_old_messages()
for message in messages[:5]:
self.assertNotEqual(MessagePrototype.get_by_id(message.id), None)
示例3: handle
# 需要导入模块: from the_tale.accounts.personal_messages.prototypes import MessagePrototype [as 别名]
# 或者: from the_tale.accounts.personal_messages.prototypes.MessagePrototype import remove_old_messages [as 别名]
def handle(self, *args, **options):
MessagePrototype.remove_old_messages()