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


Python ImapUid.folder方法代码示例

本文整理汇总了Python中inbox.models.backends.imap.ImapUid.folder方法的典型用法代码示例。如果您正苦于以下问题:Python ImapUid.folder方法的具体用法?Python ImapUid.folder怎么用?Python ImapUid.folder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inbox.models.backends.imap.ImapUid的用法示例。


在下文中一共展示了ImapUid.folder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_adding_message_to_thread

# 需要导入模块: from inbox.models.backends.imap import ImapUid [as 别名]
# 或者: from inbox.models.backends.imap.ImapUid import folder [as 别名]
def test_adding_message_to_thread(db):
    """recompute_thread_labels is not invoked when a new message is added
     (only when UID metadata changes, or when a UID is deleted). Test that
     tag changes work when adding messages to a thread."""
    account = db.session.query(Account).get(ACCOUNT_ID)
    account.namespace.create_canonical_tags()
    thread = db.session.query(Thread).get(THREAD_ID)
    account.trash_folder = Folder(name='Trash', account=account)
    FolderItem(thread=thread, folder=account.trash_folder)

    folder_names = [folder.name for folder in thread.folders]
    m = Message(namespace_id=account.namespace.id, subject='test message',
                thread_id=thread.id, received_date=datetime.datetime.now(),
                size=64, body="body", snippet="snippet")

    uid = ImapUid(account=account, message=m,
                  g_labels=['\\Inbox', 'test-label'],
                  msg_uid=22L, folder_id=account.inbox_folder.id)
    uid.folder = account.inbox_folder
    uid2 = ImapUid(account=account, message=m, g_labels=['test-2'],
                   msg_uid=24L, folder_id=account.trash_folder.id)
    uid2.folder = account.trash_folder

    thread.messages.append(m)
    add_any_new_thread_labels(thread, uid, db.session)
    add_any_new_thread_labels(thread, uid2, db.session)

    folder_names = [folder.name for folder in thread.folders]
    for folder in folder_names:
        assert folder in ['Inbox', 'Trash', 'test-label', 'test-2', '[Gmail]/All Mail', '[Gmail]/Important'],\
            "all folders should be present"

    # Now, remove the message
    m.imapuids.remove(uid2)
    db.session.delete(uid2)
    db.session.flush()

    recompute_thread_labels(thread, db.session)
    folder_names = [folder.name for folder in thread.folders]
    assert 'test-2' not in folder_names,\
        "test-2 label should have been removed from thread"
开发者ID:PriviPK,项目名称:privipk-sync-engine,代码行数:43,代码来源:test_tags_updates.py


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