コード例 #1
0
 def test_mx_msg_delete(self):
     from repoze.sendmail.maildir import MaildirTransactionalMessage
     filename1 = '/path/to/maildir/tmp/1234500002.4242.myhostname'
     filename2 = '/path/to/maildir/new/1234500002.4242.myhostname'
     self.fake_os_module.path.files[filename1] = 1
     tx_msg = MaildirTransactionalMessage(filename1, filename2)
     tx_msg.debug = True
     tx_msg.__del__()
     self.assertEqual(self.fake_os_module._removed_files, (filename1,))
コード例 #2
0
    def test_tx_msg_abort(self):
        from repoze.sendmail.maildir import MaildirTransactionalMessage
        filename1 = '/path/to/maildir/tmp/1234500002.4242.myhostname'
        filename2 = '/path/to/maildir/new/1234500002.4242.myhostname'
        tx_msg = MaildirTransactionalMessage(filename1, filename2)
        self.assertEqual(tx_msg._pending_path, filename1)

        tx_msg.abort()
        self.assertEqual(tx_msg._aborted, True)
        self.assertEqual(tx_msg._committed, False)
        self.assertTrue(filename1 in self.fake_os_module._removed_files)

        tx_msg.abort()
        self.assertRaises(RuntimeError, tx_msg.commit)
コード例 #3
0
    def test_tx_msg_commit(self):
        from repoze.sendmail.maildir import MaildirTransactionalMessage
        filename1 = '/path/to/maildir/tmp/1234500002.4242.myhostname'
        filename2 = '/path/to/maildir/new/1234500002.4242.myhostname'
        tx_msg = MaildirTransactionalMessage(filename1, filename2)
        self.assertEqual(tx_msg._pending_path, filename1)

        tx_msg.commit()
        self.assertEqual(tx_msg._aborted, False)
        self.assertEqual(tx_msg._committed, True)
        self.assertTrue((filename1, filename2)
                       in self.fake_os_module._renamed_files)

        self.assertRaises(RuntimeError, tx_msg.abort)
        self.assertRaises(RuntimeError, tx_msg.commit)