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


Python base.add_fake_imapuid函数代码示例

本文整理汇总了Python中tests.util.base.add_fake_imapuid函数的典型用法代码示例。如果您正苦于以下问题:Python add_fake_imapuid函数的具体用法?Python add_fake_imapuid怎么用?Python add_fake_imapuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_update_metadata

def test_update_metadata(db, folder):
    """Check that threads are updated correctly when a label that we haven't
    seen before is added to multiple threads -- previously, this would fail
    with an IntegrityError because autoflush was disabled."""
    first_thread = add_fake_thread(db.session, NAMESPACE_ID)
    second_thread = add_fake_thread(db.session, NAMESPACE_ID)
    uids = []

    first_thread_uids = (22222, 22223)
    for msg_uid in first_thread_uids:
        message = add_fake_message(db.session, NAMESPACE_ID, first_thread)
        uids.append(add_fake_imapuid(db.session, ACCOUNT_ID, message, folder, msg_uid))

    second_thread_uids = (22224, 22226)
    for msg_uid in second_thread_uids:
        message = add_fake_message(db.session, NAMESPACE_ID, second_thread)
        uids.append(add_fake_imapuid(db.session, ACCOUNT_ID, message, folder, msg_uid))
    db.session.add_all(uids)
    db.session.commit()

    msg_uids = first_thread_uids + second_thread_uids

    new_flags = {msg_uid: GmailFlags((), (u"\\some_new_label",)) for msg_uid in msg_uids}
    update_metadata(ACCOUNT_ID, db.session, folder.name, folder.id, msg_uids, new_flags)
    db.session.commit()
    assert "some_new_label" in [tag.name for tag in first_thread.tags]
    assert "some_new_label" in [tag.name for tag in second_thread.tags]
开发者ID:apolmig,项目名称:inbox,代码行数:27,代码来源:test_update_metadata.py

示例2: test_gmail_pagination

def test_gmail_pagination(db, default_account,
                          patch_crispin_client,
                          patch_handler_from_provider,
                          folder):
    for i in range(10):
        thread = add_fake_thread(db.session, default_account.namespace.id)
        message = add_fake_message(db.session, default_account.namespace.id,
                                   thread=thread,
                                   from_addr=[{'name': '', 'email':
                                               '{}@test.com'.format(str(i))}],
                                   subject='hi',
                                   g_msgid=i,
                                   received_date=datetime.
                                   datetime(2000 + i, 1, 1, 1, 0, 0))

        add_fake_imapuid(db.session, default_account.id, message,
                         folder, i)

    first_ten_messages_db = db.session.query(Message)\
                            .filter(Message.namespace_id ==
                                    default_account.namespace.id). \
                            order_by(desc(Message.received_date)). \
                            limit(10).all()

    api_client = new_api_client(db, default_account.namespace)

    first_ten_messages_api = api_client.get_data('/messages/search?q=hi'
                                                      '&limit=10')
    assert len(first_ten_messages_api) == len(first_ten_messages_db)

    for db_message, api_message in zip(first_ten_messages_db,
                                        first_ten_messages_api):
        assert db_message.public_id == api_message['id']

    imap_uids = db.session.query(ImapUid).join(Message) \
                    .filter(
                        ImapUid.message_id == Message.id,
                        Message.g_msgid != None).all()
    uids = [uid.msg_uid for uid in imap_uids]

    first_ten_threads_db = db.session.query(Thread) \
                            .join(Message) \
                            .join(ImapUid) \
                            .filter(ImapUid.account_id == default_account.id,
                                    ImapUid.msg_uid.in_(uids),
                                    Thread.id == Message.thread_id)\
                            .order_by(desc(Message.received_date)) \
                            .limit(10).all()

    first_ten_threads_api = api_client.get_data('/threads/search?q=hi'
                                                      '&limit=10')

    assert len(first_ten_threads_api) == len(first_ten_threads_db)

    for db_thread, api_thread in zip(first_ten_threads_db,
                                        first_ten_threads_api):
        assert db_thread.public_id == api_thread['id']
开发者ID:Eagles2F,项目名称:sync-engine,代码行数:57,代码来源:test_searching.py

示例3: test_generic_drafts_flag_constrained_by_folder

def test_generic_drafts_flag_constrained_by_folder(db, generic_account, folder_role):
    msg_uid = 22
    thread = add_fake_thread(db.session, generic_account.namespace.id)
    message = add_fake_message(db.session, generic_account.namespace.id, thread)
    folder = add_fake_folder(db.session, generic_account)
    add_fake_imapuid(db.session, generic_account.id, message, folder, msg_uid)

    new_flags = {msg_uid: Flags(("\\Draft",), None)}
    update_metadata(generic_account.id, folder.id, folder_role, new_flags, db.session)
    assert message.is_draft == (folder_role == "drafts")
开发者ID:busseyl,项目名称:sync-engine,代码行数:10,代码来源:test_update_metadata.py

示例4: test_change_labels

def test_change_labels(db, default_account, message, folder, mock_imapclient):
    mock_imapclient.add_folder_data(folder.name, {})
    mock_imapclient.add_gmail_labels = mock.Mock()
    mock_imapclient.remove_gmail_labels = mock.Mock()
    add_fake_imapuid(db.session, default_account.id, message, folder, 22)

    change_labels(default_account.id, message.id,
                  {'removed_labels': ['\\Inbox'],
                   'added_labels': [u'motörhead', u'μετάνοια']})
    mock_imapclient.add_gmail_labels.assert_called_with(
        [22], ['mot&APY-rhead', '&A7wDtQPEA6wDvQO,A7kDsQ-'])
    mock_imapclient.remove_gmail_labels.assert_called_with([22], ['\\Inbox'])
开发者ID:nagyistge,项目名称:nylas-sync-engine,代码行数:12,代码来源:test_actions.py

示例5: test_recompute_thread_labels

def test_recompute_thread_labels(db, thread, default_namespace):
    # This is smoke test that checks that a lone label gets
    # added to a thread's labels.
    account = default_namespace.account
    message = add_fake_message(db.session, default_namespace.id, thread)
    add_fake_imapuid(db.session, account.id, message,
                     account.inbox_folder, 22)
    g_labels = thread.messages[-1].imapuids[-1].g_labels

    g_labels.append('Random-label-1')
    recompute_thread_labels(thread, db.session)
    folders = {folder.name: folder for folder in thread.folders}
    assert 'Random-label-1' in folders
开发者ID:raghuveerkancherla,项目名称:sync-engine,代码行数:13,代码来源:test_tags_updates.py

示例6: test_change_labels

def test_change_labels(db, default_account, message, folder, mock_imapclient):
    mock_imapclient.add_folder_data(folder.name, {})
    mock_imapclient.add_gmail_labels = mock.Mock()
    mock_imapclient.remove_gmail_labels = mock.Mock()
    add_fake_imapuid(db.session, default_account.id, message, folder, 22)

    with writable_connection_pool(default_account.id).get() as crispin_client:
        change_labels(crispin_client, default_account.id, message.id,
                      {'removed_labels': ['\\Inbox'],
                       'added_labels': [u'motörhead', u'μετάνοια']})
        mock_imapclient.add_gmail_labels.assert_called_with(
            [22], ['mot&APY-rhead', '&A7wDtQPEA6wDvQO,A7kDsQ-'], silent=True)
        mock_imapclient.remove_gmail_labels.assert_called_with([22], ['\\Inbox'],
                                                               silent=True)
开发者ID:busseyl,项目名称:sync-engine,代码行数:14,代码来源:test_actions.py

示例7: test_change_flags

def test_change_flags(db, default_account, message, folder, mock_imapclient):
    mock_imapclient.add_folder_data(folder.name, {})
    mock_imapclient.add_flags = mock.Mock()
    mock_imapclient.remove_flags = mock.Mock()
    add_fake_imapuid(db.session, default_account.id, message, folder, 22)
    mark_unread(default_account.id, message.id, {'unread': False})
    mock_imapclient.add_flags.assert_called_with([22], ['\\Seen'])

    mark_unread(default_account.id, message.id, {'unread': True})
    mock_imapclient.remove_flags.assert_called_with([22], ['\\Seen'])

    mark_starred(default_account.id, message.id, {'starred': True})
    mock_imapclient.add_flags.assert_called_with([22], ['\\Flagged'])

    mark_starred(default_account.id, message.id, {'starred': False})
    mock_imapclient.remove_flags.assert_called_with([22], ['\\Flagged'])
开发者ID:nagyistge,项目名称:nylas-sync-engine,代码行数:16,代码来源:test_actions.py

示例8: folder_and_message_maps

def folder_and_message_maps(db, default_account):
    folder_map, message_map = {}, {}
    for name in ('all', 'trash', 'spam'):
        # Create a folder
        display_name = name.capitalize() if name != 'all' else 'All Mail'
        folder = add_fake_folder(db.session, default_account, display_name, name)
        thread = add_fake_thread(db.session, default_account.namespace.id)
        # Create a message in the folder
        message = add_fake_message(db.session, default_account.namespace.id,
                                   thread)
        add_fake_imapuid(db.session, default_account.id, message, folder, 13)
        update_message_metadata(db.session, default_account, message, False)
        db.session.commit()
        folder_map[name] = folder
        message_map[name] = message
    return folder_map, message_map
开发者ID:DrMoriarty,项目名称:sync-engine,代码行数:16,代码来源:test_labels.py

示例9: test_recompute_thread_labels_removes_trash

def test_recompute_thread_labels_removes_trash(db, default_account, thread):
    default_account.trash_folder = Folder(name='Trash',
                                          account_id=default_account.id)
    message = add_fake_message(db.session, default_account.namespace.id,
                               thread)
    add_fake_imapuid(db.session, default_account.id, message,
                     default_account.inbox_folder, 22)
    db.session.commit()

    # Check that the we remove the trash folder from a thread
    # if the latest message has the inbox flag.
    # To do this, we manufacture this situation.
    g_labels = thread.messages[-1].imapuids[-1].g_labels
    if '\\Inbox' not in g_labels:
        g_labels.append('\\Inbox')

    thread.folders.add(default_account.trash_folder)
    recompute_thread_labels(thread, db.session)
    assert default_account.trash_folder not in thread.folders,\
        "should have removed trash folder from thread"
开发者ID:raghuveerkancherla,项目名称:sync-engine,代码行数:20,代码来源:test_tags_updates.py

示例10: test_change_flags

def test_change_flags(db, default_account, message, folder, mock_imapclient):
    mock_imapclient.add_folder_data(folder.name, {})
    mock_imapclient.add_flags = mock.Mock()
    mock_imapclient.remove_flags = mock.Mock()
    add_fake_imapuid(db.session, default_account.id, message, folder, 22)
    with writable_connection_pool(default_account.id).get() as crispin_client:
        mark_unread(crispin_client, default_account.id, message.id,
                    {'unread': False})
        mock_imapclient.add_flags.assert_called_with([22], ['\\Seen'], silent=True)

        mark_unread(crispin_client, default_account.id, message.id,
                    {'unread': True})
        mock_imapclient.remove_flags.assert_called_with([22], ['\\Seen'], silent=True)

        mark_starred(crispin_client, default_account.id, message.id,
                     {'starred': True})
        mock_imapclient.add_flags.assert_called_with([22], ['\\Flagged'], silent=True)

        mark_starred(crispin_client, default_account.id, message.id,
                     {'starred': False})
        mock_imapclient.remove_flags.assert_called_with([22], ['\\Flagged'], silent=True)
开发者ID:busseyl,项目名称:sync-engine,代码行数:21,代码来源:test_actions.py

示例11: add_completely_fake_account

def add_completely_fake_account(db, email='[email protected]'):
    from inbox.models.backends.gmail import GmailAuthCredentials
    fake_account = add_fake_gmail_account(db.session, email_address=email)
    calendar = add_fake_calendar(db.session, fake_account.namespace.id)
    for i in random_range(1, 10):
        add_fake_event(db.session, fake_account.namespace.id,
                       calendar=calendar, title='%s' % i)

    # Add fake Threads, Messages and ImapUids.
    folder = add_fake_folder(db.session, fake_account)
    for i in random_range(1, 4):
        th = add_fake_thread(db.session, fake_account.namespace.id)

        for j in random_range(1, 3):
            msg = add_fake_msg_with_calendar_part(db.session,
                                                  fake_account,
                                                  'fake part', thread=th)
            db.session.add(msg)
            db.session.flush()

            for k in random_range(1, 2):
                add_fake_imapuid(db.session, fake_account.id, msg, folder,
                                 int('%s%s' % (msg.id, k)))
    # Add fake contacts
    for i in random_range(1, 5):
        add_fake_contact(db.session, fake_account.namespace.id, uid=str(i))

    auth_creds = GmailAuthCredentials()
    auth_creds.gmailaccount = fake_account
    auth_creds.scopes = "email"
    auth_creds.g_id_token = "test"
    auth_creds.client_id = "test"
    auth_creds.client_secret = "test"
    auth_creds.refresh_token = "test"
    auth_creds.is_valid = True
    db.session.add(auth_creds)
    db.session.commit()

    return fake_account
开发者ID:aabde,项目名称:sync-engine,代码行数:39,代码来源:test_namespace.py

示例12: test_deleting_from_a_message_with_multiple_uids

def test_deleting_from_a_message_with_multiple_uids(db, default_account,
                                                    message, thread):
    """Check that deleting a imapuid from a message with
    multiple uids doesn't mark the message for deletion."""
    inbox_folder = default_account.inbox_folder
    sent_folder = default_account.sent_folder

    add_fake_imapuid(db.session, default_account.id, message, sent_folder,
                     1337)
    add_fake_imapuid(db.session, default_account.id, message, inbox_folder,
                     2222)

    assert len(message.imapuids) == 2

    remove_deleted_uids(default_account.id, db.session, [2222],
                        inbox_folder.id)

    assert message.deleted_at is None, \
        "The associated message should not have been marked for deletion."

    assert len(message.imapuids) == 1, \
        "The message should have only one imapuid."
开发者ID:Analect,项目名称:sync-engine,代码行数:22,代码来源:test_delete_handling.py

示例13: sorted_imap_messages

def sorted_imap_messages(db, generic_account, sorted_imap_threads, folder):
    thread1, thread2, thread3 = sorted_imap_threads
    message1 = add_fake_message(db.session, generic_account.namespace.id,
                                 thread=thread1,
                                 from_addr=[{'name': '',
                                             'email':
                                                '[email protected]'}],
                                 to_addr=[{'name': 'Ben Bitdiddle',
                                           'email': '[email protected]'}],
                                 received_date=datetime.
                                 datetime(2015, 7, 9, 23, 50, 7),
                                 subject='YOO!')

    add_fake_imapuid(db.session, generic_account.id, message1,
                     folder, 2000)

    message2 = add_fake_message(db.session, generic_account.namespace.id,
                                 thread=thread2,
                                 from_addr=[{'name': '',
                                             'email':
                                                '[email protected]'}],
                                 to_addr=[{'name': 'Ben Bitdiddle',
                                           'email': '[email protected]'}],
                                 received_date=datetime.
                                 datetime(2014, 7, 9, 23, 50, 7),
                                 subject='Hey!')

    add_fake_imapuid(db.session, generic_account.id, message2,
                     folder, 2001)

    message3 = add_fake_message(db.session, generic_account.namespace.id,
                                 thread=thread3,
                                 from_addr=[{'name': '',
                                             'email':
                                                '[email protected]'}],
                                 to_addr=[{'name': 'Ben Bitdiddle',
                                           'email': '[email protected]'}],
                                 received_date=datetime.
                                 datetime(2013, 7, 9, 23, 50, 7),
                                 subject='Sup?')

    add_fake_imapuid(db.session, generic_account.id, message3,
                     folder, 2002)

    imap_ids.extend([2000, 2001, 2002])

    return [message1, message2, message3]
开发者ID:devwaker,项目名称:sync-engine,代码行数:47,代码来源:test_searching.py

示例14: different_imap_messages

def different_imap_messages(db, generic_account, different_sorted_imap_threads,
                            different_imap_folder):
    thread1, thread2, thread3 = different_sorted_imap_threads
    message1 = add_fake_message(db.session, generic_account.namespace.id,
                                thread=thread1,
                                from_addr=[{'name': '',
                                            'email':
                                            '[email protected]'}],
                                to_addr=[{'name': 'Ben Bitdiddle',
                                          'email': '[email protected]'}],
                                received_date=datetime.
                                datetime(2015, 7, 9, 23, 50, 7),
                                subject='LOL')

    add_fake_imapuid(db.session, generic_account.id, message1,
                     different_imap_folder, 5000)

    message2 = add_fake_message(db.session, generic_account.namespace.id,
                                thread=thread2,
                                from_addr=[{'name': '',
                                            'email':
                                            '[email protected]'}],
                                to_addr=[{'name': 'Ben Bitdiddle',
                                          'email': '[email protected]'}],
                                received_date=datetime.
                                datetime(2014, 7, 9, 23, 50, 7),
                                subject='ROTFLMO')

    add_fake_imapuid(db.session, generic_account.id, message2,
                     different_imap_folder, 5001)

    message3 = add_fake_message(db.session, generic_account.namespace.id,
                                thread=thread3,
                                from_addr=[{'name': '',
                                            'email':
                                            '[email protected]'}],
                                to_addr=[{'name': 'Ben Bitdiddle',
                                          'email': '[email protected]'}],
                                received_date=datetime.
                                datetime(2013, 7, 9, 23, 50, 7),
                                subject='ROFLCOPTER')

    add_fake_imapuid(db.session, generic_account.id, message3,
                     different_imap_folder, 5002)

    return [message1, message2, message3]
开发者ID:nagyistge,项目名称:nylas-sync-engine,代码行数:46,代码来源:test_searching.py

示例15: sorted_gmail_messages

def sorted_gmail_messages(db, default_account, sorted_gmail_threads, folder):
    thread1, thread2, thread3 = sorted_gmail_threads
    message1 = add_fake_message(db.session, default_account.namespace.id,
                                 thread=thread1,
                                 from_addr=[{'name': 'Ben Bitdiddle',
                                             'email': '[email protected]'}],
                                 to_addr=[{'name': 'Barrack Obama',
                                           'email': '[email protected]'}],
                                 g_msgid=1,
                                 received_date=datetime.
                                 datetime(2015, 7, 9, 23, 50, 7),
                                 subject='YOO!')

    add_fake_imapuid(db.session, default_account.id, message1,
                     folder, 3000)

    message2 = add_fake_message(db.session, default_account.namespace.id,
                                 thread=thread2,
                                 from_addr=[{'name': 'Ben Bitdiddle',
                                             'email': '[email protected]'}],
                                 to_addr=[{'name': 'Barrack Obama',
                                           'email': '[email protected]'}],
                                 g_msgid=2,
                                 received_date=datetime.
                                 datetime(2014, 7, 9, 23, 50, 7),
                                 subject='Hey!')

    add_fake_imapuid(db.session, default_account.id, message2,
                     folder, 3001)

    message3 = add_fake_message(db.session, default_account.namespace.id,
                                 thread=thread3,
                                 from_addr=[{'name': 'Ben Bitdiddle',
                                             'email': '[email protected]'}],
                                 to_addr=[{'name': 'Barrack Obama',
                                           'email': '[email protected]'}],
                                 g_msgid=3,
                                 received_date=datetime.
                                 datetime(2013, 7, 9, 23, 50, 7),
                                 subject='Sup?')

    add_fake_imapuid(db.session, default_account.id, message3,
                     folder, 3002)

    return [message1, message2, message3]
开发者ID:Eagles2F,项目名称:sync-engine,代码行数:45,代码来源:test_searching.py


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