本文整理汇总了Python中inbox.mailsync.gc.DeleteHandler.gc_deleted_categories方法的典型用法代码示例。如果您正苦于以下问题:Python DeleteHandler.gc_deleted_categories方法的具体用法?Python DeleteHandler.gc_deleted_categories怎么用?Python DeleteHandler.gc_deleted_categories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inbox.mailsync.gc.DeleteHandler
的用法示例。
在下文中一共展示了DeleteHandler.gc_deleted_categories方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_deleted_labels_get_gced
# 需要导入模块: from inbox.mailsync.gc import DeleteHandler [as 别名]
# 或者: from inbox.mailsync.gc.DeleteHandler import gc_deleted_categories [as 别名]
def test_deleted_labels_get_gced(db, default_account, thread, message,
imapuid, folder):
# Check that only the labels without messages attached to them
# get deleted.
default_namespace = default_account.namespace
# Create a label w/ no messages attached.
label = Label.find_or_create(db.session, default_account, 'dangling label')
label.deleted_at = datetime.utcnow()
label.category.deleted_at = datetime.utcnow()
label_id = label.id
db.session.commit()
# Create a label with attached messages.
msg_uid = imapuid.msg_uid
update_metadata(default_account.id, folder.id, folder.canonical_name,
{msg_uid: GmailFlags((), ('label',), None)}, db.session)
label_ids = []
for cat in message.categories:
for l in cat.labels:
label_ids.append(l.id)
handler = DeleteHandler(account_id=default_account.id,
namespace_id=default_namespace.id,
provider_name=default_account.provider,
uid_accessor=lambda m: m.imapuids,
message_ttl=0)
handler.gc_deleted_categories()
db.session.commit()
# Check that the first label got gc'ed
marked_deleted = db.session.query(Label).get(label_id)
assert marked_deleted is None
# Check that the other labels didn't.
for label_id in label_ids:
assert db.session.query(Label).get(label_id) is not None