summaryrefslogtreecommitdiff
path: root/tests/EmailBase.py
diff options
context:
space:
mode:
authorbwarsaw2001-10-09 20:04:49 +0000
committerbwarsaw2001-10-09 20:04:49 +0000
commit696875783a9f3b8ac46ce460fcf7bcb9d62a122a (patch)
tree62be8c133f759960ad62d9ded39059ffd0f2bf77 /tests/EmailBase.py
parent5808c7c6b430e16469458f99a53c58ead3116f6e (diff)
downloadmailman-696875783a9f3b8ac46ce460fcf7bcb9d62a122a.tar.gz
mailman-696875783a9f3b8ac46ce460fcf7bcb9d62a122a.tar.zst
mailman-696875783a9f3b8ac46ce460fcf7bcb9d62a122a.zip
Diffstat (limited to 'tests/EmailBase.py')
-rw-r--r--tests/EmailBase.py78
1 files changed, 7 insertions, 71 deletions
diff --git a/tests/EmailBase.py b/tests/EmailBase.py
index 49254925f..238e4b1d2 100644
--- a/tests/EmailBase.py
+++ b/tests/EmailBase.py
@@ -17,22 +17,14 @@
"""Base class for test that email things.
"""
+import socket
import asyncore
-import unittest
import smtpd
-import email
from Mailman import mm_cfg
-from Mailman import Message
-from Mailman import Version
from TestBase import TestBase
-# You may have to change this if there is already something running on port
-# 8025, or you aren't allowed to create sockets reading this port on
-# localhost.
-SMTPPORT = 8025
-
MSGTEXT = None
@@ -58,10 +50,12 @@ class EmailBase(TestBase):
def setUp(self):
TestBase.setUp(self)
# Second argument tuple is ignored.
- self._server = SinkServer(('localhost', SMTPPORT), ('localhost', 25))
- # Change the globals so the runner will contact the server above
- mm_cfg.SMTPHOST = 'localhost'
- mm_cfg.SMTPPORT = SMTPPORT
+ self._server = SinkServer(('localhost', mm_cfg.SMTPPORT),
+ ('localhost', 25))
+
+ def tearDown(self):
+ self._server.close()
+ TestBase.tearDown(self)
def _readmsg(self):
global MSGTEXT
@@ -79,61 +73,3 @@ class EmailBase(TestBase):
return MSGTEXT
finally:
self._mlist.Lock()
-
-
-
-class TestUserNotification(unittest.TestCase, EmailBase):
- def setUp(self):
- unittest.TestCase.setUp(self)
- EmailBase.setUp(self)
-
- def tearDown(self):
- EmailBase.tearDown(self)
- unittest.TestCase.tearDown(self)
-
- def test_user_notification(self):
- eq = self.assertEqual
- unless = self.failUnless
- msg = Message.UserNotification(
- 'aperson@dom.ain',
- '_xtest@dom.ain',
- 'Your Test List',
- 'About your test list')
- msg.send(self._mlist)
- text = self._readmsg()
- qmsg = email.message_from_string(text)
- eq(qmsg['subject'], 'Your Test List')
- eq(qmsg['from'], '_xtest@dom.ain')
- eq(qmsg['to'], 'aperson@dom.ain')
- # The Message-ID: header has some time-variant information
- msgid = qmsg['message-id']
- unless(msgid.startswith('<mailman.'))
- unless(msgid.endswith('._xtest@dom.ain>'))
- eq(qmsg['sender'], '_xtest-admin@dom.ain')
- eq(qmsg['errors-to'], '_xtest-admin@dom.ain')
- eq(qmsg['x-beenthere'], '_xtest@dom.ain')
- eq(qmsg['x-mailman-version'], Version.VERSION)
- eq(qmsg['precedence'], 'bulk')
- eq(qmsg['list-help'], '<mailto:_xtest-request@dom.ain?subject=help>')
- eq(qmsg['list-post'], '<mailto:_xtest@dom.ain>')
- eq(qmsg['list-subscribe'], """\
-<http://www.dom.ain/mailman/listinfo/_xtest>,
- <mailto:_xtest-request@dom.ain?subject=subscribe>""")
- eq(qmsg['list-id'], '<_xtest.dom.ain>')
- eq(qmsg['list-unsubscribe'], """\
-<http://www.dom.ain/mailman/listinfo/_xtest>,
- <mailto:_xtest-request@dom.ain?subject=unsubscribe>""")
- eq(qmsg['list-archive'], '<http://www.dom.ain/pipermail/_xtest/>')
- eq(qmsg.get_payload(), 'About your test list')
-
-
-
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestUserNotification))
- return suite
-
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='suite')