changeset 824:34eacaa7e313

Added ability for unit tests to turn off exception handling in mailgw so that exceptions are reported earlier (and hence make sense).
author Richard Jones <richard@users.sourceforge.net>
date Tue, 09 Jul 2002 01:21:24 +0000
parents 57f19823635b
children 0779ea9f1f18
files roundup/mailgw.py test/test_mailgw.py
diffstat 2 files changed, 42 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/mailgw.py	Tue Jul 09 01:20:01 2002 +0000
+++ b/roundup/mailgw.py	Tue Jul 09 01:21:24 2002 +0000
@@ -73,7 +73,7 @@
 an exception, the original message is bounced back to the sender with the
 explanatory message given in the exception. 
 
-$Id: mailgw.py,v 1.74 2002-05-29 01:16:17 richard Exp $
+$Id: mailgw.py,v 1.75 2002-07-09 01:21:24 richard Exp $
 '''
 
 
@@ -128,6 +128,10 @@
         self.instance = instance
         self.db = db
 
+        # should we trap exceptions (normal usage) or pass them through
+        # (for testing)
+        self.trapExceptions = 1
+
     def main(self, fp):
         ''' fp - the file from which to read the Message.
         '''
@@ -146,6 +150,8 @@
         # its way into here... try to handle it gracefully
         sendto = message.getaddrlist('from')
         if sendto:
+            if not self.trapExceptions:
+                return self.handle_message(message)
             try:
                 return self.handle_message(message)
             except MailUsageHelp:
@@ -765,6 +771,18 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.74  2002/05/29 01:16:17  richard
+# Sorry about this huge checkin! It's fixing a lot of related stuff in one go
+# though.
+#
+# . #541941 ] changing multilink properties by mail
+# . #526730 ] search for messages capability
+# . #505180 ] split MailGW.handle_Message
+#   - also changed cgi client since it was duplicating the functionality
+# . build htmlbase if tests are run using CVS checkout (removed note from
+#   installation.txt)
+# . don't create an empty message on email issue creation if the email is empty
+#
 # Revision 1.73  2002/05/22 04:12:05  richard
 #  . applied patch #558876 ] cgi client customization
 #    ... with significant additions and modifications ;)
--- a/test/test_mailgw.py	Tue Jul 09 01:20:01 2002 +0000
+++ b/test/test_mailgw.py	Tue Jul 09 01:21:24 2002 +0000
@@ -8,7 +8,7 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
-# $Id: test_mailgw.py,v 1.21 2002-06-18 03:59:59 dman13 Exp $
+# $Id: test_mailgw.py,v 1.22 2002-07-09 01:21:24 richard Exp $
 
 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib
 
@@ -106,6 +106,7 @@
 This is a test submission of a new issue.
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         nodeid = handler.main(message)
         if os.path.exists(os.environ['SENDMAILDEBUG']):
             error = open(os.environ['SENDMAILDEBUG']).read()
@@ -130,6 +131,7 @@
 This is a test submission of a new issue.
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         nodeid = handler.main(message)
         if os.path.exists(os.environ['SENDMAILDEBUG']):
             error = open(os.environ['SENDMAILDEBUG']).read()
@@ -150,6 +152,7 @@
 ''')
         userlist = self.db.user.list()
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         if os.path.exists(os.environ['SENDMAILDEBUG']):
             error = open(os.environ['SENDMAILDEBUG']).read()
@@ -169,6 +172,7 @@
 This is a test submission of a new issue.
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         if os.path.exists(os.environ['SENDMAILDEBUG']):
             error = open(os.environ['SENDMAILDEBUG']).read()
@@ -185,6 +189,7 @@
 This is a test submission of a new issue.
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         # TODO: fix the damn config - this is apalling
         self.db.config.MESSAGES_TO_AUTHOR = 'yes'
         handler.main(message)
@@ -242,6 +247,7 @@
 This is a second followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
@@ -285,6 +291,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         l = self.db.issue.get('1', 'nosy')
         l.sort()
@@ -333,6 +340,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
 
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
@@ -379,6 +387,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
 
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
@@ -426,6 +435,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
 
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
@@ -473,6 +483,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
 
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
@@ -519,6 +530,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
 
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
@@ -565,6 +577,7 @@
 This is a followup
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
 
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
@@ -609,6 +622,7 @@
 
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         l = self.db.issue.get('1', 'nosy')
         l.sort()
@@ -634,6 +648,7 @@
 
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
@@ -687,6 +702,7 @@
 
 ''')
         handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
         handler.main(message)
         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
@@ -727,6 +743,12 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.21  2002/06/18 03:59:59  dman13
+# Updated message strings to match the RFC822 address quoting performed
+# by the 'email' and 'rfc822' modules.  The verification really should
+# use a RFC2822 message parser rather than literal string comparisions
+# to allow for legal variations in messages.
+#
 # Revision 1.20  2002/05/29 01:16:17  richard
 # Sorry about this huge checkin! It's fixing a lot of related stuff in one go
 # though.

Roundup Issue Tracker: http://roundup-tracker.org/