当前位置: 首页>>代码示例>>Python>>正文


Python DeleteHandler.gc_deleted_categories方法代码示例

本文整理汇总了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
开发者ID:bdimcheff,项目名称:sync-engine,代码行数:41,代码来源:test_delete_handling.py


注:本文中的inbox.mailsync.gc.DeleteHandler.gc_deleted_categories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。