Exemplo n.º 1
0
def message_search_api():
    g.parser.add_argument('q', type=bounded_str, location='args')
    args = strict_parse_args(g.parser, request.args)
    if request.method == 'GET':
        if not args['q']:
            err_string = ('GET HTTP method must include query'
                          ' url parameter')
            g.log.error(err_string)
            return err(400, err_string)

        search_client = get_search_client(g.namespace.account)
        results = search_client.search_messages(g.db_session, args['q'])
    else:
        data = request.get_json(force=True)
        query = data.get('query')

        validate_search_query(query)

        sort = data.get('sort')
        validate_search_sort(sort)
        try:
            search_engine = NamespaceSearchEngine(g.namespace_public_id)
            results = search_engine.messages.search(query=query,
                                                    sort=sort,
                                                    max_results=args.limit,
                                                    offset=args.offset)
        except SearchEngineError as e:
            g.log.error('Search error: {0}'.format(e))
            return err(501, 'Search error')

    return g.encoder.jsonify(results)
Exemplo n.º 2
0
def test_streaming_search_results(db, imap_api_client, generic_account,
                                  imap_folder, monkeypatch, sorted_imap_messages,
                                  different_imap_messages, endpoint):
    # Check that the streaming search returns results from different
    # folders.

    class MultiFolderMockImapConnection(MockImapConnection):
        def __init__(self):
            self._responses = list(reversed([
                [2000, 2001, 2002],
                [5000, 5001],
            ]))

        def search(self, criteria, charset=None):
            self.search_args = (criteria, charset)
            return self._responses.pop()

    conn = MultiFolderMockImapConnection()
    monkeypatch.setattr(
        'inbox.auth.generic.GenericAuthHandler.connect_account',
        lambda *_, **__: conn)

    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    url = '/{}/search/streaming?q=fantastic'.format(endpoint)
    raw_data = imap_api_client.get_raw(url).data
    assert len(conn._responses) == 0, "Search should go through both folders"

    # The API returns JSON lists separated by '\n'
    responses = raw_data.split('\n')
    assert len(responses) == 3 and responses[2] == ''
    assert len(json.loads(responses[0])) == 3
    assert len(json.loads(responses[1])) == 2
Exemplo n.º 3
0
def message_search_api():
    g.parser.add_argument('q', type=bounded_str, location='args')
    args = strict_parse_args(g.parser, request.args)
    if request.method == 'GET':
        if not args['q']:
            err_string = ('GET HTTP method must include query'
                          ' url parameter')
            g.log.error(err_string)
            return err(400, err_string)

        search_client = get_search_client(g.namespace.account)
        results = search_client.search_messages(g.db_session, args['q'])
    else:
        data = request.get_json(force=True)
        query = data.get('query')

        validate_search_query(query)

        sort = data.get('sort')
        validate_search_sort(sort)
        try:
            search_engine = NamespaceSearchEngine(g.namespace_public_id)
            results = search_engine.messages.search(query=query,
                                                    sort=sort,
                                                    max_results=args.limit,
                                                    offset=args.offset)
        except SearchEngineError as e:
            g.log.error('Search error: {0}'.format(e))
            return err(501, 'Search error')

    return g.encoder.jsonify(results)
Exemplo n.º 4
0
def test_streaming_search_results(db, imap_api_client, generic_account,
                                  imap_folder, monkeypatch, sorted_imap_messages,
                                  different_imap_messages, endpoint):
    # Check that the streaming search returns results from different
    # folders.

    class MultiFolderMockImapConnection(MockImapConnection):

        def __init__(self):
            self._responses = list(reversed([
                [2000, 2001, 2002],
                [5000, 5001],
            ]))

        def search(self, criteria, charset=None):
            self.search_args = (criteria, charset)
            return self._responses.pop()

    conn = MultiFolderMockImapConnection()
    monkeypatch.setattr(
        'inbox.auth.generic.GenericAuthHandler.connect_account',
        lambda *_, **__: conn)

    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    url = '/{}/search/streaming?q=fantastic'.format(endpoint)
    raw_data = imap_api_client.get_raw(url).data
    assert len(conn._responses) == 0, "Search should go through both folders"

    # The API returns JSON lists separated by '\n'
    responses = raw_data.split('\n')
    assert len(responses) == 3 and responses[2] == ''
    assert len(json.loads(responses[0])) == 3
    assert len(json.loads(responses[1])) == 2
Exemplo n.º 5
0
def test_imap_message_search(imap_api_client, generic_account, imap_folder, imap_connection, sorted_imap_messages):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    messages = imap_api_client.get_data("/messages/search?" "q=blah%20blah%20blah")

    imap_connection.assert_search(["TEXT", "blah blah blah"])
    assert_search_result(sorted_imap_messages, messages)
Exemplo n.º 6
0
def test_gmail_thread_search(api_client, test_gmail_thread, default_account,
                             patch_token_manager, patch_gmail_search_response,
                             sorted_gmail_messages, sorted_gmail_threads):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    threads = api_client.get_data('/threads/search?q=blah%20blah%20blah')

    assert_search_result(sorted_gmail_threads, threads)
Exemplo n.º 7
0
def test_imap_thread_search(imap_api_client, generic_account,
                            patch_crispin_client, sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 8
0
def test_gmail_message_search(
    api_client, default_account, patch_token_manager, patch_gmail_search_response, sorted_gmail_messages
):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    messages = api_client.get_data("/messages/search?q=blah%20blah%20blah")

    assert_search_result(sorted_gmail_messages, messages)
Exemplo n.º 9
0
def test_gmail_thread_search(api_client, test_gmail_thread, default_account,
                             patch_crispin_client, patch_handler_from_provider,
                             sorted_gmail_threads):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    threads = api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 10
0
def test_imap_thread_search(imap_api_client, generic_account,
                            patch_crispin_client, patch_handler_from_provider,
                            sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 11
0
def test_imap_thread_search_unicode(
    db, imap_api_client, generic_account, imap_folder, imap_connection, sorted_imap_messages, sorted_imap_threads
):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data("/threads/search?q=存档")

    imap_connection.assert_search([u"TEXT", u"\u5b58\u6863"], "UTF-8")
    assert_search_result(sorted_imap_threads, threads)
Exemplo n.º 12
0
def test_imap_thread_search(
    imap_api_client, test_imap_thread, generic_account, patch_crispin_client, patch_handler_from_provider, test_imap_uid
):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == "IMAPSearchClient"

    threads = imap_api_client.get_data("/threads/search?q=blah%20blah%20blah")

    assert len(threads) == 1
    assert threads[0]["id"] == test_imap_thread.public_id
Exemplo n.º 13
0
def test_gmail_message_search(api_client, default_account, patch_token_manager,
                              patch_gmail_search_response,
                              sorted_gmail_messages):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_gmail_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 14
0
def test_imap_message_search(imap_api_client, generic_account,
                             patch_crispin_client, sorted_imap_messages):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    messages = imap_api_client.get_data('/messages/search?'
                                        'q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_imap_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 15
0
def test_gmail_thread_search(api_client, test_gmail_thread, default_account,
                             patch_token_manager, patch_gmail_search_response,
                             sorted_gmail_threads):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    threads = api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 16
0
def test_imap_thread_search_unicode(db, imap_api_client, generic_account,
                                    imap_folder, imap_connection,
                                    sorted_imap_messages, sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=存档')

    imap_connection.assert_search([u"TEXT", u"\u5b58\u6863"], "UTF-8")
    assert_search_result(sorted_imap_threads, threads)
Exemplo n.º 17
0
def test_imap_search_unicode(db, imap_api_client, generic_account,
                             patch_crispin_client, sorted_imap_threads):
    Folder.find_or_create(db.session, generic_account, '存档', '存档')
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 18
0
def test_imap_thread_search(imap_api_client, generic_account,
                             patch_crispin_client,
                             sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 19
0
def test_imap_thread_search(imap_api_client, generic_account, imap_folder,
                            imap_connection, sorted_imap_messages,
                            sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    imap_connection.assert_search(["TEXT", "blah blah blah"])
    assert_search_result(sorted_imap_threads, threads)
Exemplo n.º 20
0
def test_gmail_message_search(api_client, default_account,
                              patch_token_manager,
                              patch_gmail_search_response,
                              sorted_gmail_messages):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_gmail_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 21
0
def test_imap_thread_search(imap_api_client, generic_account,
                            imap_folder, imap_connection,
                            sorted_imap_messages,
                            sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    imap_connection.assert_search(["TEXT", "blah blah blah"])
    assert_search_result(sorted_imap_threads, threads)
Exemplo n.º 22
0
def test_gmail_thread_search(api_client, test_gmail_thread, default_account,
                             patch_crispin_client,
                             patch_handler_from_provider,
                             test_gmail_imap_uid):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    threads = api_client.get_data('/threads/search?q=blah%20blah%20blah')

    assert len(threads) == 1
    assert threads[0]['id'] == test_gmail_thread.public_id
Exemplo n.º 23
0
def test_imap_message_search(imap_api_client, generic_account,
                              patch_crispin_client,
                              sorted_imap_messages):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    messages = imap_api_client.get_data('/messages/search?'
                                        'q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_imap_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 24
0
def test_gmail_thread_search(api_client, test_gmail_thread, default_account,
                             patch_token_manager,
                             patch_gmail_search_response,
                             sorted_gmail_threads):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    threads = api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 25
0
def test_gmail_message_search(api_client, test_gmail_message, default_account,
                              patch_crispin_client,
                              patch_handler_from_provider,
                              test_gmail_imap_uid):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    assert len(messages) == 1
    assert messages[0]['id'] == test_gmail_message.public_id
Exemplo n.º 26
0
def test_imap_thread_search(imap_api_client, test_imap_thread, generic_account,
                             patch_crispin_client,
                             patch_handler_from_provider,
                             test_imap_uid):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    assert len(threads) == 1
    assert threads[0]['id'] == test_imap_thread.public_id
Exemplo n.º 27
0
def test_gmail_message_search(api_client, default_account,
                              patch_crispin_client,
                              patch_handler_from_provider,
                              sorted_gmail_messages):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_gmail_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 28
0
def test_imap_thread_search(imap_api_client, generic_account,
                             patch_crispin_client,
                             patch_handler_from_provider,
                             sorted_imap_threads):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    threads = imap_api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 29
0
def test_gmail_search_unicode(db, api_client, test_gmail_thread,
                              patch_token_manager, patch_gmail_search_response,
                              default_account, sorted_gmail_threads):
    Folder.find_or_create(db.session, default_account, '存档', '存档')
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    threads = api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 30
0
def test_imap_message_search(imap_api_client, generic_account,
                             patch_crispin_client, patch_handler_from_provider,
                             sorted_imap_messages):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    messages = imap_api_client.get_data('/messages/search?'
                                        'q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_imap_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 31
0
def test_imap_search_unicode(db, imap_api_client, generic_account,
                             patch_crispin_client, patch_handler_from_provider,
                             sorted_imap_threads):
    Folder.find_or_create(db.session, generic_account, '存档', '存档')
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    threads = imap_api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 32
0
def test_gmail_thread_search(api_client, test_gmail_thread, default_account,
                             patch_crispin_client,
                             patch_handler_from_provider,
                             sorted_gmail_threads):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    threads = api_client.get_data('/threads/search?q=blah%20blah%20blah')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 33
0
def test_gmail_message_search(api_client, default_account,
                              patch_crispin_client,
                              patch_handler_from_provider,
                              sorted_gmail_messages):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_gmail_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 34
0
def test_imap_search_unicode(db, imap_api_client, generic_account,
                             patch_crispin_client,
                             sorted_imap_threads):
    Folder.find_or_create(db.session, generic_account,
                          '存档', '存档')
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    threads = imap_api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 35
0
def test_gmail_search_unicode(db, api_client, test_gmail_thread,
                              patch_token_manager,
                              patch_gmail_search_response,
                              default_account,
                              sorted_gmail_messages,
                              sorted_gmail_threads):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    threads = api_client.get_data('/threads/search?q=存档')

    assert_search_result(sorted_gmail_threads, threads)
Exemplo n.º 36
0
def test_gmail_search_unicode(db, api_client, test_gmail_thread,
                              default_account, patch_crispin_client,
                              patch_handler_from_provider,
                              sorted_gmail_threads):
    Folder.find_or_create(db.session, default_account, '存档', '存档')
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    threads = api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 37
0
def test_imap_message_search(imap_api_client, generic_account,
                              patch_crispin_client,
                              patch_handler_from_provider,
                              sorted_imap_messages):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    messages = imap_api_client.get_data('/messages/search?'
                                        'q=blah%20blah%20blah')

    for sorted_message, result_message in zip(sorted_imap_messages, messages):
        assert sorted_message.public_id == result_message['id']
Exemplo n.º 38
0
def test_imap_message_search(imap_api_client, test_imap_message,
                              generic_account,
                              patch_crispin_client,
                              patch_handler_from_provider,
                              test_imap_uid):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    messages = imap_api_client.get_data('/messages/search?'
                                        'q=blah%20blah%20blah')

    assert len(messages) == 1
    assert messages[0]['id'] == test_imap_message.public_id
Exemplo n.º 39
0
def test_gmail_message_search(api_client, default_account, patch_token_manager,
                              patch_gmail_search_response,
                              sorted_gmail_messages, is_streaming):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    if is_streaming:
        messages = api_client.get_data(
            '/messages/search/streaming?q=blah%20blah%20blah')
    else:
        messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    assert_search_result(sorted_gmail_messages, messages)
Exemplo n.º 40
0
def test_gmail_search_unicode(db, api_client, test_gmail_thread,
                              patch_token_manager, patch_gmail_search_response,
                              default_account, sorted_gmail_messages,
                              sorted_gmail_threads, is_streaming):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    if is_streaming:
        threads = api_client.get_data('/threads/search/streaming?q=存档')
    else:
        threads = api_client.get_data('/threads/search?q=存档')

    assert_search_result(sorted_gmail_threads, threads)
Exemplo n.º 41
0
def test_imap_search_unicode(db, imap_api_client, generic_account,
                             patch_crispin_client,
                             patch_handler_from_provider,
                             sorted_imap_threads):
    Folder.find_or_create(db.session, generic_account,
                          '存档', '存档')
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == 'IMAPSearchClient'

    threads = imap_api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_imap_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 42
0
def test_gmail_message_search(api_client, default_account,
                              patch_token_manager,
                              patch_gmail_search_response,
                              sorted_gmail_messages, is_streaming):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    if is_streaming:
        messages = api_client.get_data('/messages/search/streaming?q=blah%20blah%20blah')
    else:
        messages = api_client.get_data('/messages/search?q=blah%20blah%20blah')

    assert_search_result(sorted_gmail_messages, messages)
Exemplo n.º 43
0
def test_gmail_search_unicode(db, api_client, test_gmail_thread,
                              patch_token_manager,
                              patch_gmail_search_response,
                              default_account,
                              sorted_gmail_threads):
    Folder.find_or_create(db.session, default_account,
                          '存档', '存档')
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    threads = api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 44
0
def test_gmail_search_unicode(db, api_client, test_gmail_thread,
                              default_account,
                              patch_crispin_client,
                              patch_handler_from_provider,
                              sorted_gmail_threads):
    Folder.find_or_create(db.session, default_account,
                          '存档', '存档')
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == 'GmailSearchClient'

    threads = api_client.get_data('/threads/search?q=存档')

    for sorted_thread, result_thread in zip(sorted_gmail_threads, threads):
        assert sorted_thread.public_id == result_thread['id']
Exemplo n.º 45
0
def test_imap_message_search(imap_api_client, generic_account,
                             imap_folder, imap_connection,
                             sorted_imap_messages, is_streaming):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    if is_streaming:
        messages = imap_api_client.get_data('/messages/search/streaming?'
                                            'q=blah%20blah%20blah')
    else:
        messages = imap_api_client.get_data('/messages/search?'
                                            'q=blah%20blah%20blah')

    imap_connection.assert_search(["TEXT", "blah blah blah"])
    assert_search_result(sorted_imap_messages, messages)
Exemplo n.º 46
0
def test_gmail_message_search(
    api_client,
    test_gmail_message,
    default_account,
    patch_crispin_client,
    patch_handler_from_provider,
    test_gmail_imap_uid,
):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == "GmailSearchClient"

    messages = api_client.get_data("/messages/search?q=blah%20blah%20blah")

    assert len(messages) == 1
    assert messages[0]["id"] == test_gmail_message.public_id
Exemplo n.º 47
0
def test_gmail_thread_search(
    api_client,
    test_gmail_thread,
    default_account,
    patch_crispin_client,
    patch_handler_from_provider,
    test_gmail_imap_uid,
):
    search_client = get_search_client(default_account)
    assert search_client.__class__.__name__ == "GmailSearchClient"

    threads = api_client.get_data("/threads/search?q=blah%20blah%20blah")

    assert len(threads) == 1
    assert threads[0]["id"] == test_gmail_thread.public_id
Exemplo n.º 48
0
def test_imap_message_search(imap_api_client, generic_account, imap_folder,
                             imap_connection, sorted_imap_messages,
                             is_streaming):
    search_client = get_search_client(generic_account)
    assert isinstance(search_client, IMAPSearchClient)

    if is_streaming:
        messages = imap_api_client.get_data('/messages/search/streaming?'
                                            'q=blah%20blah%20blah')
    else:
        messages = imap_api_client.get_data('/messages/search?'
                                            'q=blah%20blah%20blah')

    imap_connection.assert_search(["TEXT", "blah blah blah"])
    assert_search_result(sorted_imap_messages, messages)
Exemplo n.º 49
0
def test_imap_message_search(
    imap_api_client,
    test_imap_message,
    generic_account,
    patch_crispin_client,
    patch_handler_from_provider,
    test_imap_uid,
):
    search_client = get_search_client(generic_account)
    assert search_client.__class__.__name__ == "IMAPSearchClient"

    messages = imap_api_client.get_data("/messages/search?" "q=blah%20blah%20blah")

    assert len(messages) == 1
    assert messages[0]["id"] == test_imap_message.public_id
Exemplo n.º 50
0
def test_gmail_thread_search(
    api_client,
    test_gmail_thread,
    default_account,
    patch_token_manager,
    patch_gmail_search_response,
    sorted_gmail_messages,
    sorted_gmail_threads,
    is_streaming,
):
    search_client = get_search_client(default_account)
    assert isinstance(search_client, GmailSearchClient)

    if is_streaming:
        threads = api_client.get_data(
            "/threads/search/streaming?q=blah%20blah%20blah")
    else:
        threads = api_client.get_data("/threads/search?q=blah%20blah%20blah")

    assert_search_result(sorted_gmail_threads, threads)