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'])
Esempio n. 2
0
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-'])
        mock_imapclient.remove_gmail_labels.assert_called_with([22], ['\\Inbox'])
Esempio n. 3
0
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)
Esempio n. 4
0
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)