summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2008-07-06 10:27:05 -0400
committerBarry Warsaw2008-07-06 10:27:05 -0400
commit3929c688da2b275a1bb965152cca8a7352557ffc (patch)
treeef32ee1e5ac61570f3059ae838b30049b7055936
parent08400a46afb740a0e49058707969462fa7e7dddf (diff)
downloadmailman-3929c688da2b275a1bb965152cca8a7352557ffc.tar.gz
mailman-3929c688da2b275a1bb965152cca8a7352557ffc.tar.zst
mailman-3929c688da2b275a1bb965152cca8a7352557ffc.zip
-rw-r--r--mailman/archiving/mailarchive.py2
-rw-r--r--mailman/docs/archivers.txt24
-rw-r--r--mailman/queue/docs/outgoing.txt20
-rw-r--r--mailman/tests/test_documentation.py8
4 files changed, 17 insertions, 37 deletions
diff --git a/mailman/archiving/mailarchive.py b/mailman/archiving/mailarchive.py
index e1405acee..2a83b9a8d 100644
--- a/mailman/archiving/mailarchive.py
+++ b/mailman/archiving/mailarchive.py
@@ -68,7 +68,7 @@ class MailArchive:
end = (-1 if message_id.endswith('>') else None)
message_id = message_id[start:end]
sha = hashlib.sha1(message_id)
- sha.update(str(mlist.post_id))
+ sha.update(str(mlist.posting_address))
message_id_hash = urlsafe_b64encode(sha.digest())
del msg['x-message-id-hash']
msg['X-Message-ID-Hash'] = message_id_hash
diff --git a/mailman/docs/archivers.txt b/mailman/docs/archivers.txt
index edd82ba1e..96cdb5c3d 100644
--- a/mailman/docs/archivers.txt
+++ b/mailman/docs/archivers.txt
@@ -31,7 +31,7 @@ interoperate.
... print ' ', archiver.permalink(mlist, msg)
mail-archive
http://go.mail-archive.dev/test%40example.com
- http://go.mail-archive.dev/7ekn-OQjGKjbAsD3StwtnhZ3Azk=
+ http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc=
pipermail
http://www.example.com/pipermail/test@example.com
None
@@ -75,20 +75,14 @@ automatically.
>>> archiver = config.archivers['mail-archive']
>>> archiver.list_url(mlist)
'http://go.mail-archive.dev/test%40example.com'
-
- >>> mlist.post_id = 77
>>> archiver.permalink(mlist, msg)
- 'http://go.mail-archive.dev/8FhWFYqR61sszkBLk4rEc0YNWks='
+ 'http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc='
To archive the message, the archiver actually mails the message to a special
address at the Mail-Archive.
>>> archiver.archive_message(mlist, msg)
- >>> from mailman.testing.helpers import SMTPServer
- >>> smtpd = SMTPServer()
- >>> smtpd.start()
-
>>> from mailman.queue.outgoing import OutgoingRunner
>>> from mailman.testing.helpers import make_testable_runner
>>> outgoing = make_testable_runner(OutgoingRunner)
@@ -104,7 +98,7 @@ address at the Mail-Archive.
To: test@example.com
Subject: An archived message
Message-ID: <12345>
- X-Message-ID-Hash: 8FhWFYqR61sszkBLk4rEc0YNWks=
+ X-Message-ID-Hash: ZaXPPxRMM9_hFZL4vTRlQlBx8pc=
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
@@ -140,20 +134,14 @@ Additionally, this archiver can handle malformed Message-IDs.
>>> del msg['message-id']
>>> msg['Message-ID'] = '12345>'
>>> archiver.permalink(mlist, msg)
- 'http://go.mail-archive.dev/8FhWFYqR61sszkBLk4rEc0YNWks='
+ 'http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc='
>>> del msg['message-id']
>>> msg['Message-ID'] = '<12345'
>>> archiver.permalink(mlist, msg)
- 'http://go.mail-archive.dev/8FhWFYqR61sszkBLk4rEc0YNWks='
+ 'http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc='
>>> del msg['message-id']
>>> msg['Message-ID'] = '12345'
>>> archiver.permalink(mlist, msg)
- 'http://go.mail-archive.dev/8FhWFYqR61sszkBLk4rEc0YNWks='
-
-
-Clean up
---------
-
- >>> smtpd.stop()
+ 'http://go.mail-archive.dev/ZaXPPxRMM9_hFZL4vTRlQlBx8pc='
diff --git a/mailman/queue/docs/outgoing.txt b/mailman/queue/docs/outgoing.txt
index ba6cc6d96..cfb6c6988 100644
--- a/mailman/queue/docs/outgoing.txt
+++ b/mailman/queue/docs/outgoing.txt
@@ -26,21 +26,12 @@ move messages to the 'retry queue' for handling delivery failures.
... u'password', DeliveryMode.regular, u'en',
... ack=False, admin_notif=False)
- >>> from mailman.testing.helpers import SMTPServer
- >>> smtpd = SMTPServer()
- >>> smtpd.start()
- >>> from mailman.configuration import config
- >>> old_host = config.SMTPHOST
- >>> old_port = config.SMTPPORT
- >>> config.SMTPHOST = smtpd.host
- >>> config.SMTPPORT = smtpd.port
-
By setting the mailing list to personalize messages, each recipient will get a
unique copy of the message, with certain headers tailored for that recipient.
>>> from mailman.interfaces import Personalization
>>> mlist.personalize = Personalization.individual
- >>> config.db.commit()
+ >>> commit()
>>> msg = message_from_string("""\
... From: aperson@example.com
@@ -55,6 +46,7 @@ Normally, messages would show up in the outgoing queue after the message has
been processed by the rule set and pipeline. But we can simulate that here by
injecting a message directly into the outgoing queue.
+ >>> from mailman.configuration import config
>>> msgdata = {}
>>> handler = config.handlers['calculate-recipients']
>>> handler.process(mlist, msg, msgdata)
@@ -86,11 +78,3 @@ Three messages have been delivered to our SMTP server, one for each recipient.
test-bounces+aperson=example.com@example.com
test-bounces+bperson=example.com@example.com
test-bounces+cperson=example.com@example.com
-
-
-Clean up
---------
-
- >>> smtpd.stop()
- >>> config.SMTPHOST = old_host
- >>> config.SMTPPORT = old_port
diff --git a/mailman/tests/test_documentation.py b/mailman/tests/test_documentation.py
index 48c2c491c..2d42f989d 100644
--- a/mailman/tests/test_documentation.py
+++ b/mailman/tests/test_documentation.py
@@ -29,6 +29,7 @@ import mailman
from mailman.Message import Message
from mailman.app.styles import style_manager
from mailman.configuration import config
+from mailman.testing.helpers import SMTPServer
DOT = '.'
@@ -54,12 +55,15 @@ def specialized_message_from_string(text):
def setup(testobj):
"""Test setup."""
+ smtpd = SMTPServer()
+ smtpd.start()
# In general, I don't like adding convenience functions, since I think
# doctests should do the imports themselves. It makes for better
# documentation that way. However, a few are really useful, or help to
# hide some icky test implementation details.
testobj.globs['message_from_string'] = specialized_message_from_string
testobj.globs['commit'] = config.db.commit
+ testobj.globs['smtpd'] = smtpd
@@ -82,6 +86,10 @@ def cleaning_teardown(testobj):
# Reset all archivers by disabling them.
for archiver in config.archivers.values():
archiver.is_enabled = False
+ # Shutdown the smtp server.
+ smtpd = testobj.globs['smtpd']
+ smtpd.clear()
+ smtpd.stop()