Example #1
0
    def test_max_ids_one_user_one_mail(self):
        server_state = ServerState()
        server_state.add_mail('user', Mail.create(['user']))

        self.assertEquals(1, server_state.max_id('user', 'INBOX'))
        self.assertEquals(1, server_state.max_uid('user'))
        self.assertEquals(0, server_state.max_id('user', 'OTHER_MAILBOX'))
Example #2
0
    def test_reprocess_ids_if_a_message_is_removed(self):
        server_state = ServerState()
        server_state.add_mail('user',
                              Mail.create(['user'], 'from1'),
                              mailbox='INBOX')
        server_state.add_mail('user',
                              Mail.create(['user'], 'from2'),
                              mailbox='INBOX')
        server_state.add_mail('user',
                              Mail.create(['user'], 'from3'),
                              mailbox='INBOX')

        server_state.remove_byid('user', 'INBOX', 1)
        self.assertEqual(
            1,
            server_state.get_mailbox_messages('user', 'INBOX')[0].id)
        self.assertEqual(
            2,
            server_state.get_mailbox_messages('user', 'INBOX')[1].id)
        self.assertEquals(2, server_state.max_id('user', 'INBOX'))
        self.assertEquals(3, server_state.max_uid('user', 'INBOX'))

        server_state.remove_byid('user', 'INBOX', 1)
        self.assertEqual(
            1,
            server_state.get_mailbox_messages('user', 'INBOX')[0].id)
        self.assertEquals(1, server_state.max_id('user', 'INBOX'))
        self.assertEquals(3, server_state.max_uid('user', 'INBOX'))
Example #3
0
    def test_max_ids_one_user_one_mail(self):
        server_state = ServerState()
        server_state.add_mail('user', Mail.create(['user']))

        self.assertEquals(1, server_state.max_id('user', 'INBOX'))
        self.assertEquals(1, server_state.max_uid('user', 'INBOX'))
        self.assertEquals(0, server_state.max_id('user', 'OTHER_MAILBOX'))
Example #4
0
    def test_max_ids_one_user_two_mails_one_per_mailbox(self):
        server_state = ServerState()
        server_state.add_mail('user', Mail.create(['user']), mailbox='INBOX')
        server_state.add_mail('user', Mail.create(['user']), mailbox='OUTBOX')

        self.assertEquals(1, server_state.max_id('user', 'INBOX'))
        self.assertEquals(1, server_state.max_id('user', 'OUTBOX'))
        self.assertEquals(2, server_state.max_uid('user'))
Example #5
0
    def test_max_ids_one_user_three_mails_in_two_mailboxes(self):
        server_state = ServerState()
        server_state.add_mail('user', Mail.create(['user']), mailbox='INBOX')
        server_state.add_mail('user', Mail.create(['user']), mailbox='INBOX')
        server_state.add_mail('user', Mail.create(['user']), mailbox='OUTBOX')

        self.assertEquals(1, server_state.max_id('user', 'OUTBOX'))
        self.assertEquals(2, server_state.max_id('user', 'INBOX'))
        self.assertEquals(2, server_state.max_uid('user', 'INBOX'))
Example #6
0
    def test_reprocess_ids_if_a_message_is_removed(self):
        server_state = ServerState()
        server_state.add_mail('user', Mail.create(['user'], 'from1'), mailbox='INBOX')
        server_state.add_mail('user', Mail.create(['user'], 'from2'), mailbox='INBOX')
        server_state.add_mail('user', Mail.create(['user'], 'from3'), mailbox='INBOX')

        server_state.remove_byid('user', 'INBOX', 1)
        self.assertEqual(1, server_state.get_mailbox_messages('user', 'INBOX')[0].id)
        self.assertEqual(2, server_state.get_mailbox_messages('user', 'INBOX')[1].id)
        self.assertEquals(2, server_state.max_id('user', 'INBOX'))
        self.assertEquals(3, server_state.max_uid('user', 'INBOX'))

        server_state.remove_byid('user', 'INBOX', 1)
        self.assertEqual(1, server_state.get_mailbox_messages('user', 'INBOX')[0].id)
        self.assertEquals(1, server_state.max_id('user', 'INBOX'))
        self.assertEquals(3, server_state.max_uid('user', 'INBOX'))