Update of /cvsroot/mailman/mailman/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv30852/tests

Modified Files:
      Tag: Release_2_1-maint
        fblast.py test_handlers.py test_membership.py 
        test_security_mgr.py testall.py 
Log Message:
Backporting from trunk


Index: fblast.py
===================================================================
RCS file: /cvsroot/mailman/mailman/tests/fblast.py,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- fblast.py   13 Mar 2002 05:59:40 -0000      1.1
+++ fblast.py   31 Mar 2003 22:04:40 -0000      1.1.2.1
@@ -54,7 +54,7 @@
 """ % {'num'     : i,
        'FROMADDR': FROMADDR,
        'LISTADDR': LISTADDR,
-       }
+       })
         time.sleep(snooze)
 finally:
     conn.quit()

Index: test_handlers.py
===================================================================
RCS file: /cvsroot/mailman/mailman/tests/test_handlers.py,v
retrieving revision 2.9
retrieving revision 2.9.2.1
diff -u -d -r2.9 -r2.9.2.1
--- test_handlers.py    14 Apr 2002 06:04:09 -0000      2.9
+++ test_handlers.py    31 Mar 2003 22:04:41 -0000      2.9.2.1
@@ -1,31 +1,31 @@
-# Copyright (C) 2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software 
+# along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 """Unit tests for the various Mailman/Handlers/*.py modules.
 """
 
 import os
-import time
 import sha
-import unittest
-import cPickle
-import errno
+import time
 import email
-from email.Generator import Generator
+import errno
+import cPickle
+import unittest
 from types import ListType
+from email.Generator import Generator
 
 from Mailman import mm_cfg
 from Mailman.MailList import MailList
@@ -45,10 +45,8 @@
 from Mailman.Handlers import Hold
 from Mailman.Handlers import MimeDel
 from Mailman.Handlers import Moderate
-from Mailman.Handlers import Personalize
 from Mailman.Handlers import Replybot
-from Mailman.Handlers import SMTPDirect
-from Mailman.Handlers import Sendmail
+# Don't test handlers such as SMTPDirect and Sendmail here
 from Mailman.Handlers import SpamDetect
 from Mailman.Handlers import Tagger
 from Mailman.Handlers import ToArchive
@@ -72,6 +70,7 @@
         self._sb = Switchboard(mm_cfg.VIRGINQUEUE_DIR)
         # Add a member
         self._mlist.addNewMember('[EMAIL PROTECTED]')
+        self._mlist.personalize = False
 
     def tearDown(self):
         for f in os.listdir(mm_cfg.VIRGINQUEUE_DIR):
@@ -146,6 +145,7 @@
 was successfully received by the _xtest mailing list.
 
 List info page: http://www.dom.ain/mailman/listinfo/_xtest
+Your preferences: http://www.dom.ain/mailman/options/_xtest/aperson%40dom.ain
 """)
         # Make sure we dequeued the only message
         eq(len(self._sb.files()), 0)
@@ -185,46 +185,7 @@
 was successfully received by the _xtest mailing list.
 
 List info page: http://www.dom.ain/mailman/listinfo/_xtest
-""")
-        # Make sure we dequeued the only message
-        eq(len(self._sb.files()), 0)
-
-    def test_ack_with_prefixed_subject(self):
-        eq = self.assertEqual
-        self._mlist.subject_prefix = '[XTEST] '
-        self._mlist.setMemberOption(
-            '[EMAIL PROTECTED]', mm_cfg.AcknowledgePosts, 1)
-        eq(len(self._sb.files()), 0)
-        msg = email.message_from_string("""\
-From: [EMAIL PROTECTED]
-Subject: [XTEST] Wish you were here
-
-""", Message.Message)
-        Acknowledge.process(self._mlist, msg, {})
-        files = self._sb.files()
-        eq(len(files), 1)
-        qmsg, qdata = self._sb.dequeue(files[0])
-        # Check the .db file
-        eq(qdata.get('listname'), '_xtest')
-        eq(qdata.get('recips'), ['[EMAIL PROTECTED]'])
-        eq(qdata.get('version'), 3)
-        # Check the .pck
-        eq(str(qmsg['subject']), '_xtest post acknowledgement')
-        eq(qmsg['to'], '[EMAIL PROTECTED]')
-        eq(qmsg['from'], '[EMAIL PROTECTED]')
-        eq(qmsg.get_type(), 'text/plain')
-        eq(qmsg.get_param('charset'), 'us-ascii')
-        msgid = qmsg['message-id']
-        self.failUnless(msgid.startswith('<mailman.'))
-        self.failUnless(msgid.endswith('[EMAIL PROTECTED]>'))
-        eq(qmsg.get_payload(), """\
-Your message entitled
-
-    Wish you were here
-
-was successfully received by the _xtest mailing list.
-
-List info page: http://www.dom.ain/mailman/listinfo/_xtest
+Your preferences: http://www.dom.ain/mailman/options/_xtest/aperson%40dom.ain
 """)
         # Make sure we dequeued the only message
         eq(len(self._sb.files()), 0)
@@ -555,7 +516,7 @@
 
 """, Message.Message)
         CookHeaders.process(self._mlist, msg, {})
-        eq(msg['precedence'], 'bulk')
+        eq(msg['precedence'], 'list')
 
     def test_existing_precedence(self):
         eq = self.assertEqual
@@ -574,7 +535,9 @@
 From: [EMAIL PROTECTED]
 
 """, Message.Message)
-        CookHeaders.process(self._mlist, msg, {})
+        msgdata = {}
+        CookHeaders.process(self._mlist, msg, msgdata)
+        self.assertEqual(msgdata.get('origsubj'), '')
         self.assertEqual(str(msg['subject']), '[XTEST] (no subject)')
 
     def test_subject_munging(self):
@@ -794,7 +757,7 @@
 XTest header
 Here is a message.
 XTest footer""")
-        
+
     def test_no_multipart_type_error(self):
         mlist = self._mlist
         mlist.msg_header = '%(real_name) header\n'
@@ -810,7 +773,7 @@
 %(real_name) header
 Here is a message.
 %(real_name) footer""")
-        
+
     def test_no_multipart_value_error(self):
         mlist = self._mlist
         # These will generate warnings in logs/error
@@ -827,7 +790,7 @@
 %(real_name)p header
 Here is a message.
 %(real_name)p footer""")
-        
+
     def test_no_multipart_missing_key(self):
         mlist = self._mlist
         mlist.msg_header = '%(spooge)s header\n'
@@ -842,7 +805,7 @@
 %(spooge)s header
 Here is a message.
 %(spooge)s footer""")
-        
+
     def test_multipart(self):
         mlist = self._mlist
         mlist.msg_header = 'header\n'
@@ -871,6 +834,7 @@
 Content-Type: text/plain; charset="us-ascii"
 MIME-Version: 1.0
 Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
 
 header
 
@@ -888,12 +852,14 @@
 Content-Type: text/plain; charset="us-ascii"
 MIME-Version: 1.0
 Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
 
 footer
 
 --BOUNDARY--""")
 
     def test_image(self):
+        eq = self.assertEqual
         mlist = self._mlist
         mlist.msg_header = 'header\n'
         mlist.msg_footer = 'footer'
@@ -904,7 +870,8 @@
 IMAGEDATAIMAGEDATAIMAGEDATA
 """)
         Decorate.process(self._mlist, msg, {})
-        self.assertEqual(msg.get_payload(), """\
+        eq(len(msg.get_payload()), 3)
+        self.assertEqual(msg.get_payload(1).get_payload(), """\
 IMAGEDATAIMAGEDATAIMAGEDATA
 """)
 
@@ -1164,6 +1131,7 @@
         TestBase.setUp(self)
         self._mlist.filter_content = 1
         self._mlist.filter_mime_types = ['image/jpeg']
+        self._mlist.pass_mime_types = []
         self._mlist.convert_html_to_plaintext = 1
 
     def test_outer_matches(self):
@@ -1249,7 +1217,7 @@
 """)
         MimeDel.process(self._mlist, msg, {})
         eq(msg.get_type(), 'text/plain')
-        eq(msg.get_payload(), '\n   \n\n')
+        eq(msg.get_payload(), '\n\n\n')
 
     def test_deep_structure(self):
         eq = self.assertEqual
@@ -1339,16 +1307,6 @@
 
 
 
-class TestSMTPDirect(TestBase):
-    pass
-
-
-
-class TestSendmail(TestBase):
-    pass
-
-
-
 class TestSpamDetect(TestBase):
     def test_short_circuit(self):
         msgdata = {'approved': 1}
@@ -1565,7 +1523,7 @@
         fp = open(self._path, 'w')
         g = Generator(fp)
         for i in range(5):
-            g(self._makemsg(i), unixfrom=1)
+            g.flatten(self._makemsg(i), unixfrom=1)
         fp.close()
         self._sb = Switchboard(mm_cfg.VIRGINQUEUE_DIR)
 
@@ -1609,13 +1567,14 @@
         # is the RFC 1153 digest.
         for filebase in files:
             qmsg, qdata = self._sb.dequeue(filebase)
-            if qmsg['mime-version']:
+            if qmsg.get_main_type() == 'multipart':
                 mimemsg = qmsg
                 mimedata = qdata
             else:
                 rfc1153msg = qmsg
                 rfc1153data = qdata
-        eq(mimemsg.get_type(), 'multipart/mixed')
+        eq(rfc1153msg.get_content_type(), 'text/plain')
+        eq(mimemsg.get_content_type(), 'multipart/mixed')
         eq(mimemsg['from'], mlist.GetRequestEmail())
         eq(mimemsg['subject'],
            '%(realname)s Digest, Vol %(volume)d, Issue %(issue)d' % {
@@ -1652,12 +1611,11 @@
         eq(len(files), 1)
         msg2, data = self._sb.dequeue(files[0])
         eq(msg.as_string(unixfrom=0), msg2.as_string(unixfrom=0))
-        eq(len(data), 6)
+        eq(len(data), 5)
         eq(data['foo'], 1)
         eq(data['bar'], 2)
         eq(data['version'], 3)
         eq(data['listname'], '_xtest')
-        eq(data['verp'], 0)
         # Clock skew makes this unreliable
         #self.failUnless(data['received_time'] <= time.time())
 

Index: test_membership.py
===================================================================
RCS file: /cvsroot/mailman/mailman/tests/test_membership.py,v
retrieving revision 2.3
retrieving revision 2.3.2.1
diff -u -d -r2.3 -r2.3.2.1
--- test_membership.py  9 Feb 2002 03:22:35 -0000       2.3
+++ test_membership.py  31 Mar 2003 22:04:42 -0000      2.3.2.1
@@ -1,17 +1,17 @@
-# Copyright (C) 2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software 
+# along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 """Unit tests for OldStyleMemberships.
@@ -84,7 +84,7 @@
                                  password='xxXXxx',
                                  language='xx',
                                  realname='A. Nice Person')
-        
+
     def test_add_member(self):
         eq = self.assertEqual
         mlist = self._mlist
@@ -97,7 +97,7 @@
         eq(mlist.getMemberCPAddresses(('[EMAIL PROTECTED]', '[EMAIL PROTECTED]')),
            ['[EMAIL PROTECTED]', None])
         eq(mlist.getMemberPassword('[EMAIL PROTECTED]'), 'xxXXxx')
-        eq(mlist.getMemberLanguage('[EMAIL PROTECTED]'), 'xx')
+        eq(mlist.getMemberLanguage('[EMAIL PROTECTED]'), 'en')
         eq(mlist.getMemberOption('[EMAIL PROTECTED]', mm_cfg.Digests), 0)
         eq(mlist.getMemberOption('[EMAIL PROTECTED]', mm_cfg.AcknowledgePosts), 0)
         eq(mlist.getMemberName('[EMAIL PROTECTED]'), 'A. Nice Person')
@@ -163,7 +163,7 @@
         eq(mlist.getMemberCPAddresses(('[EMAIL PROTECTED]', '[EMAIL PROTECTED]')),
            ['[EMAIL PROTECTED]', None])
         eq(mlist.getMemberPassword('[EMAIL PROTECTED]'), 'xxXXxx')
-        eq(mlist.getMemberLanguage('[EMAIL PROTECTED]'), 'xx')
+        eq(mlist.getMemberLanguage('[EMAIL PROTECTED]'), 'en')
         eq(mlist.getMemberOption('[EMAIL PROTECTED]', mm_cfg.Digests), 0)
         eq(mlist.getMemberOption('[EMAIL PROTECTED]', mm_cfg.AcknowledgePosts), 0)
         eq(mlist.getMemberName('[EMAIL PROTECTED]'), 'A. Nice Person')
@@ -195,8 +195,9 @@
         self.failIf(mlist.authenticateMember('[EMAIL PROTECTED]', 'xxXXxx'))
 
     def test_set_language(self):
-        self._mlist.setMemberLanguage('[EMAIL PROTECTED]', 'yy')
-        self.assertEqual(self._mlist.getMemberLanguage('[EMAIL PROTECTED]'), 'yy')
+        self._mlist.available_languages.append('xx')
+        self._mlist.setMemberLanguage('[EMAIL PROTECTED]', 'xx')
+        self.assertEqual(self._mlist.getMemberLanguage('[EMAIL PROTECTED]'), 'xx')
 
     def test_basic_option(self):
         eq = self.assertEqual

Index: test_security_mgr.py
===================================================================
RCS file: /cvsroot/mailman/mailman/tests/test_security_mgr.py,v
retrieving revision 2.0
retrieving revision 2.0.2.1
diff -u -d -r2.0 -r2.0.2.1
--- test_security_mgr.py        9 Oct 2001 20:08:13 -0000       2.0
+++ test_security_mgr.py        31 Mar 2003 22:04:43 -0000      2.0.2.1
@@ -1,17 +1,17 @@
-# Copyright (C) 2001 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software 
+# along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 """Unit tests for Mailman/SecurityManager.py
@@ -27,7 +27,8 @@
     import crypt
 except ImportError:
     crypt = None
-from cStringIO import StringIO
+# Don't use cStringIO because we're going to inherit
+from StringIO import StringIO
 
 from Mailman import mm_cfg
 from Mailman import Utils
@@ -101,7 +102,7 @@
         except OSError, e:
             if e.errno <> errno.ENOENT: raise
         TestBase.tearDown(self)
-        
+
     def test_auth_creator(self):
         self.assertEqual(self._mlist.Authenticate(
             [mm_cfg.AuthCreator], 'ccCCcc'), mm_cfg.AuthCreator)
@@ -176,7 +177,7 @@
     def test_no_user(self):
         mlist = self._mlist
         mlist.addNewMember('[EMAIL PROTECTED]', password='nosrepa')
-        self.assertRaises(TypeError, mlist.Authenticate,
+        self.assertRaises(AttributeError, mlist.Authenticate,
                           [mm_cfg.AuthUser], 'nosrepa')
 
     def test_user_unauth(self):
@@ -192,6 +193,14 @@
 
 
 
+class StripperIO(StringIO):
+    HEAD = 'Set-Cookie: '
+    def write(self, s):
+        if s.startswith(self.HEAD):
+            s = s[len(self.HEAD):]
+        StringIO.write(self, s)
+
+
 class TestWebAuthenticate(TestBase):
     def setUp(self):
         TestBase.setUp(self)
@@ -201,13 +210,15 @@
         mlist.mod_password = password('abcdefg')
         mlist.addNewMember('[EMAIL PROTECTED]', password='qqQQqq')
         # Set up the cookie data
-        sfp = StringIO()
+        sfp = StripperIO()
         print >> sfp, mlist.MakeCookie(mm_cfg.AuthSiteAdmin)
         # AuthCreator isn't handled in AuthContextInfo()
         print >> sfp, mlist.MakeCookie(mm_cfg.AuthListAdmin)
         print >> sfp, mlist.MakeCookie(mm_cfg.AuthListModerator)
         print >> sfp, mlist.MakeCookie(mm_cfg.AuthUser, '[EMAIL PROTECTED]')
-        os.environ['HTTP_COOKIE'] = sfp.getvalue()
+        # Strip off the "Set-Cookie: " prefix
+        cookie = sfp.getvalue()
+        os.environ['HTTP_COOKIE'] = cookie
 
     def tearDown(self):
         try:
@@ -218,6 +229,7 @@
             os.unlink(mm_cfg.LISTCREATOR_PW_FILE)
         except OSError, e:
             if e.errno <> errno.ENOENT: raise
+        del os.environ['HTTP_COOKIE']
         TestBase.tearDown(self)
 
     def test_auth_site_admin(self):

Index: testall.py
===================================================================
RCS file: /cvsroot/mailman/mailman/tests/testall.py,v
retrieving revision 2.4
retrieving revision 2.4.2.1
diff -u -d -r2.4 -r2.4.2.1
--- testall.py  13 Mar 2002 06:00:59 -0000      2.4
+++ testall.py  31 Mar 2003 22:04:44 -0000      2.4.2.1
@@ -1,17 +1,17 @@
-# Copyright (C) 2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software 
+# along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 """PyUnit-based test harness for Mailman."""
@@ -19,7 +19,7 @@
 import unittest
 
 MODULES = ('bounces', 'handlers', 'membership', 'safedict',
-           'security_mgr', 'runners', 'lockfile',
+           'security_mgr', 'runners', 'lockfile', 'smtp',
            )
 
 # test_message.py can only be run when mailmanctl is running, but mailmanctl



_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to