How to use aioimaplib - 10 common examples

To help you get started, we’ve selected a few aioimaplib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_uid_with_illegal_command(self):
        imap_client = yield from self.login_user('user', 'pass', select=True)

        for command in {'COPY', 'FETCH', 'STORE'}.symmetric_difference(Commands.keys()):
            with self.assertRaises(aioimaplib.Abort) as expected:
                yield from imap_client.uid(command)

            self.assertEqual(expected.exception.args,
                             ('command UID only possible with COPY, FETCH or STORE (was %s)' % command,))
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_login(self):
        imap_client = aioimaplib.IMAP4(port=12345, loop=self.loop, timeout=3)
        yield from asyncio.wait_for(imap_client.wait_hello_from_server(), 2)

        result, data = yield from imap_client.login('user', 'password')

        self.assertEquals(aioimaplib.AUTH, imap_client.protocol.state)
        self.assertEqual('OK', result)
        self.assertEqual('LOGIN completed', data[-1])
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_capabilities(self):
        imap_client = aioimaplib.IMAP4(port=12345, loop=self.loop)
        yield from asyncio.wait_for(imap_client.wait_hello_from_server(), 2)

        self.assertEquals('IMAP4REV1', imap_client.protocol.imap_version)
        self.assertEquals(['IMAP4rev1', 'LITERAL+', 'IDLE'], imap_client.protocol.capabilities)
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def login_user(self, login, password, select=False, lib=aioimaplib.IMAP4):
        imap_client = aioimaplib.IMAP4(port=12345, loop=self.loop, timeout=3)
        yield from asyncio.wait_for(imap_client.wait_hello_from_server(), 2)

        yield from imap_client.login('user', 'password')

        if select:
            yield from imap_client.select()
        return imap_client
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
    def login_user(self, login, password, select=False, lib=aioimaplib.IMAP4):
        imap_client = aioimaplib.IMAP4(port=12345, loop=self.loop, timeout=3)
        yield from asyncio.wait_for(imap_client.wait_hello_from_server(), 2)

        yield from imap_client.login('user', 'password')

        if select:
            yield from imap_client.select()
        return imap_client
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_login_twice(self):
        with self.assertRaises(aioimaplib.Error) as expected:
            imap_client = yield from self.login_user('user', 'pass')

            yield from imap_client.login('user', 'password')

        self.assertEqual(expected.exception.args, ('command LOGIN illegal in state AUTH',))
github bamthomas / aioimaplib / tests / example.py View on Github external
def fetch_mail(host, user, password):
    imap_client = aioimaplib.IMAP4_SSL(host=host)
    yield from imap_client.wait_hello_from_server()

    yield from imap_client.login(user, password)

    res, data = yield from imap_client.select()
    print('there is %s messages INBOX' % data[0])

    yield from imap_client.logout()
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_split_responses_with_message_data_expunge(self):
        self.assertEquals([b'* 123 EXPUNGE', b'TAG OK SELECT completed.'],
                          _split_responses(b'* 123 EXPUNGE\r\nTAG OK SELECT completed.\r\n'))
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_split_responses_regular_lines(self):
        self.assertEquals([b'* BYE Logging out', b'CAPB2 OK LOGOUT completed'],
                          _split_responses(b'* BYE Logging out\r\nCAPB2 OK LOGOUT completed\r\n'))
github bamthomas / aioimaplib / tests / test_aioimaplib.py View on Github external
def test_split_responses_with_message_data(self):
        self.assertEquals([b'* FETCH ...\r\n(mail content)\r\n...\r\n)',
                           b'TAG OK FETCH completed.'],
                          _split_responses(
                              b'* 1 FETCH (UID 1 RFC822 {26}\r\n...\r\n(mail content)\r\n...\r\n)\r\n'
                              b'TAG OK FETCH completed.'))