------------------------------------------------------------
revno: 1119
committer: Mark Sapiro <[email protected]>
branch nick: 2.2
timestamp: Sun 2010-07-11 10:16:50 -0700
message:
  Updated unit tests for current Mailman so all tests should pass.
modified:
  tests/EmailBase.py
  tests/test_bounces.py
  tests/test_handlers.py
  tests/test_lockfile.py
  tests/test_membership.py
  tests/test_message.py
  tests/test_runners.py
  tests/test_safedict.py
  tests/test_security_mgr.py
  tests/test_smtp.py


--
lp:mailman/2.2
https://code.launchpad.net/~mailman-coders/mailman/2.2

Your team Mailman Checkins is subscribed to branch lp:mailman/2.2.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.2/+edit-subscription
=== modified file 'tests/EmailBase.py'
--- tests/EmailBase.py	2005-08-27 01:40:17 +0000
+++ tests/EmailBase.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -49,6 +49,8 @@
 class EmailBase(TestBase):
     def setUp(self):
         TestBase.setUp(self)
+        if mm_cfg.SMTPPORT == 0:
+            mm_cfg.SMTPPORT = 25
         # Second argument tuple is ignored.
         self._server = SinkServer(('localhost', mm_cfg.SMTPPORT),
                                   ('localhost', 25))

=== modified file 'tests/test_bounces.py'
--- tests/test_bounces.py	2009-07-31 20:14:43 +0000
+++ tests/test_bounces.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2009 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -21,6 +21,10 @@
 import os
 import unittest
 import email
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman.Bouncers.BouncerAPI import Stop
 

=== modified file 'tests/test_handlers.py'
--- tests/test_handlers.py	2008-12-01 04:30:43 +0000
+++ tests/test_handlers.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2008 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -26,6 +26,10 @@
 import unittest
 from types import ListType
 from email.Generator import Generator
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman import mm_cfg
 from Mailman.MailList import MailList
@@ -208,7 +212,7 @@
 class TestApprove(TestBase):
     def test_short_circuit(self):
         msgdata = {'approved': 1}
-        rtn = Approve.process(self._mlist, None, msgdata)
+        rtn = Approve.process(self._mlist, Message.Message(), msgdata)
         # Not really a great test, but there's little else to assert
         self.assertEqual(rtn, None)
 
@@ -549,7 +553,7 @@
 
 """, Message.Message)
         CookHeaders.process(self._mlist, msg, {})
-        self.assertEqual(msg['subject'], '[XTEST] About Mailman...')
+        self.assertEqual(str(msg['subject']), '[XTEST] About Mailman...')
 
     def test_no_subject_munging_for_digests(self):
         self._mlist.subject_prefix = '[XTEST] '
@@ -579,7 +583,9 @@
 
 """, Message.Message)
         CookHeaders.process(self._mlist, msg, {})
-        self.assertEqual(msg['subject'], 'Re: [XTEST] About Mailman...')
+        # prefixing depends on mm_cfg.py
+        self.failUnless(str(msg['subject']) == 'Re: [XTEST] About Mailman...' or
+                        str(msg['subject']) == '[XTEST] Re: About Mailman...')
 
     def test_reply_to_list(self):
         eq = self.assertEqual
@@ -692,7 +698,7 @@
         eq(msg['list-id'], '<_xtest.dom.ain>')
         eq(msg['list-help'], '<mailto:[email protected]?subject=help>')
         eq(msg['list-unsubscribe'],
-           '<http://www.dom.ain/mailman/listinfo/_xtest>,'
+           '<http://www.dom.ain/mailman/options/_xtest>,'
            '\n\t<mailto:[email protected]?subject=unsubscribe>')
         eq(msg['list-subscribe'],
            '<http://www.dom.ain/mailman/listinfo/_xtest>,'
@@ -709,10 +715,10 @@
 
 """, Message.Message)
         CookHeaders.process(self._mlist, msg, {})
-        eq(msg['list-id'].__unicode__(), 'A Test List <_xtest.dom.ain>')
+        eq(unicode(msg['list-id']), 'A Test List <_xtest.dom.ain>')
         eq(msg['list-help'], '<mailto:[email protected]?subject=help>')
         eq(msg['list-unsubscribe'],
-           '<http://www.dom.ain/mailman/listinfo/_xtest>,'
+           '<http://www.dom.ain/mailman/options/_xtest>,'
            '\n\t<mailto:[email protected]?subject=unsubscribe>')
         eq(msg['list-subscribe'],
            '<http://www.dom.ain/mailman/listinfo/_xtest>,'
@@ -1115,7 +1121,7 @@
         cookie = confirmlines[-3].split('/')[-1]
         # We also need to make sure there's an entry in the Pending database
         # for the heold message.
-        data = Pending.confirm(cookie)
+        data = self._mlist.pend_confirm(cookie)
         eq(data, ('H', 1))
         heldmsg = os.path.join(mm_cfg.DATA_DIR, 'heldmsg-_xtest-1.pck')
         self.failUnless(os.path.exists(heldmsg))
@@ -1499,7 +1505,8 @@
         files = self._sb.files()
         eq(len(files), 1)
         msg2, data = self._sb.dequeue(files[0])
-        eq(len(data), 2)
+        eq(len(data), 3)
+        eq(data['_parsemsg'], False)
         eq(data['version'], 3)
         # Clock skew makes this unreliable
         #self.failUnless(data['received_time'] <= time.time())
@@ -1567,7 +1574,7 @@
         # is the RFC 1153 digest.
         for filebase in files:
             qmsg, qdata = self._sb.dequeue(filebase)
-            if qmsg.get_main_type() == 'multipart':
+            if qmsg.get_content_maintype() == 'multipart':
                 mimemsg = qmsg
                 mimedata = qdata
             else:
@@ -1611,12 +1618,14 @@
         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)
+        self.failUnless(len(data) >= 6 and len(data) <= 7)
         eq(data['foo'], 1)
         eq(data['bar'], 2)
         eq(data['version'], 3)
         eq(data['listname'], '_xtest')
-        eq(data['verp'], 1)
+        eq(data['_parsemsg'], False)
+        # Can't test verp. presence/value depend on mm_cfg.py
+        #eq(data['verp'], 1)
         # Clock skew makes this unreliable
         #self.failUnless(data['received_time'] <= time.time())
 

=== modified file 'tests/test_lockfile.py'
--- tests/test_lockfile.py	2005-08-27 01:40:17 +0000
+++ tests/test_lockfile.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2002 by the Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 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
@@ -18,6 +18,10 @@
 """
 
 import unittest
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman.LockFile import LockFile
 

=== modified file 'tests/test_membership.py'
--- tests/test_membership.py	2005-08-27 01:40:17 +0000
+++ tests/test_membership.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -20,6 +20,10 @@
 import os
 import time
 import unittest
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman import mm_cfg
 from Mailman import Utils
@@ -196,6 +200,7 @@
 
     def test_set_language(self):
         self._mlist.available_languages.append('xx')
+        mm_cfg.LC_DESCRIPTIONS.setdefault('xx', 0)
         self._mlist.setMemberLanguage('[email protected]', 'xx')
         self.assertEqual(self._mlist.getMemberLanguage('[email protected]'), 'xx')
 

=== modified file 'tests/test_message.py'
--- tests/test_message.py	2008-12-01 04:30:43 +0000
+++ tests/test_message.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2008 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -17,8 +17,13 @@
 """Unit tests for the various Message class methods.
 """
 
+import sys
 import unittest
 import email
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman import Message
 from Mailman import Version
@@ -28,7 +33,7 @@
 
 
 
-class TestSentMessage(EmailBase):
+class TestSentMessage1(EmailBase):
     def test_user_notification(self):
         eq = self.assertEqual
         unless = self.failUnless
@@ -46,23 +51,16 @@
         msgid = qmsg['message-id']
         unless(msgid.startswith('<mailman.'))
         unless(msgid.endswith('[email protected]>'))
-        eq(qmsg['sender'], '[email protected]')
-        eq(qmsg['errors-to'], '[email protected]')
+        eq(qmsg['sender'], '[email protected]')
+        eq(qmsg['errors-to'], '[email protected]')
         eq(qmsg['x-beenthere'], '[email protected]')
         eq(qmsg['x-mailman-version'], Version.VERSION)
         eq(qmsg['precedence'], 'bulk')
-        eq(qmsg['list-help'], '<mailto:[email protected]?subject=help>')
-        eq(qmsg['list-post'], '<mailto:[email protected]>')
-        eq(qmsg['list-subscribe'], """\
-<http://www.dom.ain/mailman/listinfo/_xtest>,
-	<mailto:[email protected]?subject=subscribe>""")
         eq(qmsg['list-id'], '<_xtest.dom.ain>')
-        eq(qmsg['list-unsubscribe'], """\
-<http://www.dom.ain/mailman/listinfo/_xtest>,
-	<mailto:[email protected]?subject=unsubscribe>""")
-        eq(qmsg['list-archive'], '<http://www.dom.ain/pipermail/_xtest>')
+        eq(qmsg['x-list-administrivia'], 'yes')
         eq(qmsg.get_payload(), 'About your test list')
 
+class TestSentMessage2(EmailBase):
     def test_bounce_message(self):
         eq = self.assertEqual
         unless = self.failUnless
@@ -82,21 +80,35 @@
         # message.
         msg1 = qmsg.get_payload(0)
         eq(msg1.get_content_type(), 'text/plain')
-        eq(msg1.get_payload(), '[No bounce details are available]\n')
+        eq(msg1.get_payload(), '[No bounce details are available]')
         msg2 = qmsg.get_payload(1)
         eq(msg2.get_content_type(), 'message/rfc822')
-        unless(not msg2.is_multipart())
-        msg3 = msg2.get_payload()
+        unless(msg2.is_multipart())
+        msg3 = msg2.get_payload(0)
         eq(msg3.get_payload(), 'yadda yadda yadda\n')
 
 
 
-def suite():
+def suite(x):
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(TestSentMessage))
+    if x == '1':
+        suite.addTest(unittest.makeSuite(TestSentMessage1))
+    elif x == '2':
+        suite.addTest(unittest.makeSuite(TestSentMessage2))
     return suite
 
 
 
 if __name__ == '__main__':
-    unittest.main(defaultTest='suite')
+    # There is some issue in asyncore.py that prevents successfully running more than
+    # one test at a time, so specify which of the two tests as an argument.
+    if len(sys.argv) == 1:
+        x = '1'
+    else:
+        x = sys.argv[1]
+    if x not in ('1', '2'):
+        print >> sys.stderr, (
+            'usage: python test_message.py [n] where n = 1, 2 is the sub-test to run.')
+        sys.exit(1)
+    unittest.TextTestRunner(verbosity=2).run(suite(x)) 
+

=== modified file 'tests/test_runners.py'
--- tests/test_runners.py	2005-08-27 01:40:17 +0000
+++ tests/test_runners.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -19,6 +19,10 @@
 
 import unittest
 import email
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman.Queue.NewsRunner import prepare_message
 

=== modified file 'tests/test_safedict.py'
--- tests/test_safedict.py	2005-08-27 01:40:17 +0000
+++ tests/test_safedict.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -19,6 +19,10 @@
 
 import email
 import unittest
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman import SafeDict
 

=== modified file 'tests/test_security_mgr.py'
--- tests/test_security_mgr.py	2008-11-13 04:02:29 +0000
+++ tests/test_security_mgr.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2008 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2010 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
@@ -28,6 +28,10 @@
     crypt = None
 # Don't use cStringIO because we're going to inherit
 from StringIO import StringIO
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman import mm_cfg
 from Mailman import Utils
@@ -171,14 +175,16 @@
     def test_wrong_user(self):
         mlist = self._mlist
         mlist.addNewMember('[email protected]', password='nosrepa')
-        self.assertRaises(Errors.NotAMemberError, mlist.Authenticate,
-                          [mm_cfg.AuthUser], 'nosrepa', '[email protected]')
+        self.assertEqual(mlist.Authenticate(
+                [mm_cfg.AuthUser], 'nosrepa', '[email protected]'),
+                mm_cfg.UnAuthorized)
 
     def test_no_user(self):
         mlist = self._mlist
         mlist.addNewMember('[email protected]', password='nosrepa')
-        self.assertRaises(AttributeError, mlist.Authenticate,
-                          [mm_cfg.AuthUser], 'nosrepa')
+        self.assertEqual(mlist.Authenticate(
+                [mm_cfg.AuthUser], 'nosrepa'),
+                mm_cfg.UnAuthorized)
 
     def test_user_unauth(self):
         mlist = self._mlist

=== modified file 'tests/test_smtp.py'
--- tests/test_smtp.py	2005-08-27 01:40:17 +0000
+++ tests/test_smtp.py	2010-07-11 17:16:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2003-2010 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
@@ -20,6 +20,10 @@
 import email
 import unittest
 import thread
+try:
+    from Mailman import __init__
+except ImportError:
+    import paths
 
 from Mailman import mm_cfg
 from Mailman.Handlers import SMTPDirect

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to