예제 #1
0
파일: test_gmail.py 프로젝트: naspeh/mailur
def test_account(gm_client):
    params = {
        'username': '******',
        'password': '******',
        'imap_host': 'imap.gmail.com',
        'smtp_host': 'smtp.gmail.com'
    }
    remote.data_account(params.copy())
    assert remote.data_account.get() == dict(
        params, gmail=True, smtp_port=587, imap_port=993,
    )

    params = {
        'username': '******',
        'password': '******',
        'imap_host': 'imap.test.com',
        'smtp_host': 'smtp.test.com'
    }
    remote.data_account(params.copy())
    assert remote.data_account.get() == dict(
        params, smtp_port=587, imap_port=993,
    )

    gm_client.list = [('OK', [
        b'(\\HasNoChildren \\All) "/" mlr/All',
    ])]
    assert remote.get_folders() == [{'tag': '\\All'}]

    gm_client.list = [('OK', [
        b'(\\HasNoChildren) "/" INBOX',
    ])]
    assert remote.get_folders() == [{'box': 'INBOX', 'tag': '\\Inbox'}]
예제 #2
0
def test_account(gm_client):
    params = {
        'username': '******',
        'password': '******',
        'imap_host': 'imap.gmail.com',
        'smtp_host': 'smtp.gmail.com'
    }
    remote.data_account(params.copy())
    assert remote.data_account.get() == dict(
        params, gmail=True, smtp_port=587, imap_port=993,
    )

    params = {
        'username': '******',
        'password': '******',
        'imap_host': 'imap.test.com',
        'smtp_host': 'smtp.test.com'
    }
    remote.data_account(params.copy())
    assert remote.data_account.get() == dict(
        params, smtp_port=587, imap_port=993,
    )

    gm_client.list = [('OK', [
        b'(\\HasNoChildren \\All) "/" mlr/All',
    ])]
    assert remote.get_folders() == [{'tag': '\\All'}]

    gm_client.list = [('OK', [
        b'(\\HasNoChildren) "/" INBOX',
    ])]
    assert remote.get_folders() == [{'box': 'INBOX', 'tag': '\\Inbox'}]
예제 #3
0
파일: test_sync.py 프로젝트: naspeh/mailur
def test_cli_idle2(gm_client, msgs, login, patch):
    remote.data_account({
        'username': '******',
        'password': '******',
        'imap_host': 'imap.test.com',
        'smtp_host': 'smtp.test.com'
    })
    assert remote.get_folders() == [{'tag': '\\All'}]

    spawn(lambda: cli.main('sync %s --timeout=300' % login.user1))
    sleep(2)

    gm_client.add_emails([{}] * 4, fetch=False, parse=False)
    gm_client.fetch = [gm_client.fetch[0]]
    sleep(2)
    assert len(msgs(local.SRC)) == 4
    assert len(msgs()) == 4

    gm_client.list = []
    xlist = [('OK', [b'(\\HasNoChildren) "/" INBOX'])] * 10
    with patch.object(gm_client, 'list', xlist):
        spawn(lambda: cli.main('sync %s --timeout=300' % login.user1))
        sleep(2)

        gm_client.add_emails([{'flags': '#inbox'}], fetch=False, parse=False)
        gm_client.fetch = [gm_client.fetch[0]]
        sleep(2)
        assert len(msgs(local.SRC)) == 5
        assert len(msgs()) == 5
        assert len(msgs('INBOX')) == 1
예제 #4
0
파일: test_sync.py 프로젝트: staser/mailur
def test_cli_idle2(gm_client, msgs, login, patch):
    remote.data_account({
        'username': '******',
        'password': '******',
        'imap_host': 'imap.test.com',
        'smtp_host': 'smtp.test.com'
    })
    assert remote.get_folders() == [{'tag': '\\All'}]

    spawn(lambda: cli.main('sync %s --timeout=300' % login.user1))
    sleep(2)

    gm_client.add_emails([{}] * 4, fetch=False, parse=False)
    gm_client.fetch = [gm_client.fetch[0]]
    sleep(2)
    assert len(msgs(local.SRC)) == 4
    assert len(msgs()) == 4

    gm_client.list = []
    xlist = [('OK', [b'(\\HasNoChildren) "/" INBOX'])] * 10
    with patch.object(gm_client, 'list', xlist):
        spawn(lambda: cli.main('sync %s --timeout=300' % login.user1))
        sleep(2)

        gm_client.add_emails([{'flags': '#inbox'}], fetch=False, parse=False)
        gm_client.fetch = [gm_client.fetch[0]]
        sleep(2)
        assert len(msgs(local.SRC)) == 5
        assert len(msgs()) == 5
        assert len(msgs('INBOX')) == 1
예제 #5
0
def setup(new_users, gm_client, sendmail, patch_conf):
    from mailur import imap, local, remote

    global con_local, con_gmail

    con_local = local.client(None)
    con_gmail = local.connect(*local.master_login(username=test2))

    remote.data_account({
        'username': '******',
        'password': '******',
        'imap_host': 'imap.gmail.com',
        'smtp_host': 'smtp.gmail.com',
    })

    yield

    con_local.logout()
    con_gmail.logout()
    imap.clean_pool(test1)
    imap.clean_pool(test2)