~barry/mailman/work1

« back to all changes in this revision

Viewing changes to src/mailman/runners/tests/test_lmtp.py

  • Committer: Barry Warsaw
  • Date: 2013-03-11 19:24:48 UTC
  • mfrom: (7178.2.26 3.0)
  • Revision ID: barry@list.org-20130311192448-gb1h8ca77weapdkx
trunk merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2012 by the Free Software Foundation, Inc.
 
1
# Copyright (C) 2012-2013 by the Free Software Foundation, Inc.
2
2
#
3
3
# This file is part of GNU Mailman.
4
4
#
25
25
    ]
26
26
 
27
27
 
 
28
import os
28
29
import smtplib
29
30
import unittest
30
31
 
31
32
from datetime import datetime
32
33
 
 
34
from mailman.config import config
33
35
from mailman.app.lifecycle import create_list
34
36
from mailman.database.transaction import transaction
35
37
from mailman.testing.helpers import get_lmtp_client, get_queue_messages
64
66
        # (e.g., mailbox not found, no access, or command rejected for policy
65
67
        # reasons)
66
68
        self.assertEqual(cm.exception.smtp_code, 550)
67
 
        self.assertEqual(cm.exception.smtp_error, 
 
69
        self.assertEqual(cm.exception.smtp_error,
68
70
                         'No Message-ID header provided')
69
71
 
70
72
    def test_message_id_hash_is_added(self):
109
111
        self.assertEqual(len(messages), 1)
110
112
        self.assertEqual(messages[0].msgdata['received_time'],
111
113
                         datetime(2005, 8, 1, 7, 49, 23))
 
114
 
 
115
    def test_queue_directory(self):
 
116
        # The LMTP runner is not queue runner, so it should not have a
 
117
        # directory in var/queue.
 
118
        queue_directory = os.path.join(config.QUEUE_DIR, 'lmtp')
 
119
        self.assertFalse(os.path.isdir(queue_directory))
 
120
 
 
121
 
 
122
 
 
123
class TestBugs(unittest.TestCase):
 
124
    """Test some LMTP related bugs."""
 
125
 
 
126
    layer = LMTPLayer
 
127
 
 
128
    def setUp(self):
 
129
        self._lmtp = get_lmtp_client(quiet=True)
 
130
        self._lmtp.lhlo('remote.example.org')
 
131
 
 
132
    def test_lp1117176(self):
 
133
        # Upper cased list names can't be sent to via LMTP.
 
134
        with transaction():
 
135
            create_list('my-LIST@example.com')
 
136
        self._lmtp.sendmail('anne@example.com', ['my-list@example.com'], """\
 
137
From: anne@example.com
 
138
To: my-list@example.com
 
139
Subject: My subject
 
140
Message-ID: <alpha>
 
141
 
 
142
""")
 
143
        messages = get_queue_messages('in')
 
144
        self.assertEqual(len(messages), 1)
 
145
        self.assertEqual(messages[0].msgdata['listname'],
 
146
                         'my-list@example.com')