Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 1945:7e4058dfb29b
ignore incoming email with "Precedence: bulk" (patch [SF#843489])
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 04 Dec 2003 23:34:25 +0000 |
| parents | 20cfd25cffda |
| children | 18e77fe2a669 |
comparison
equal
deleted
inserted
replaced
| 1944:23fd363ece42 | 1945:7e4058dfb29b |
|---|---|
| 6 # | 6 # |
| 7 # This module is distributed in the hope that it will be useful, | 7 # This module is distributed in the hope that it will be useful, |
| 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 # | 10 # |
| 11 # $Id: test_mailgw.py,v 1.62 2003-11-13 03:41:38 richard Exp $ | 11 # $Id: test_mailgw.py,v 1.63 2003-12-04 23:34:25 richard Exp $ |
| 12 | 12 |
| 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 | 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 |
| 14 | 14 |
| 15 from cStringIO import StringIO | 15 from cStringIO import StringIO |
| 16 | 16 |
| 17 if not os.environ.has_key('SENDMAILDEBUG'): | 17 if not os.environ.has_key('SENDMAILDEBUG'): |
| 18 os.environ['SENDMAILDEBUG'] = 'mail-test.log' | 18 os.environ['SENDMAILDEBUG'] = 'mail-test.log' |
| 19 SENDMAILDEBUG = os.environ['SENDMAILDEBUG'] | 19 SENDMAILDEBUG = os.environ['SENDMAILDEBUG'] |
| 20 | 20 |
| 21 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, parseContent | 21 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \ |
| 22 parseContent, IgnoreLoop, IgnoreBulk | |
| 22 from roundup import init, instance, rfc2822 | 23 from roundup import init, instance, rfc2822 |
| 23 | 24 |
| 24 | 25 |
| 25 class Message(rfc822.Message): | 26 class Message(rfc822.Message): |
| 26 """String-based Message class with equivalence test.""" | 27 """String-based Message class with equivalence test.""" |
| 959 assert not os.path.exists(SENDMAILDEBUG) | 960 assert not os.path.exists(SENDMAILDEBUG) |
| 960 l = self.db.issue.get(nodeid, 'nosy') | 961 l = self.db.issue.get(nodeid, 'nosy') |
| 961 l.sort() | 962 l.sort() |
| 962 self.assertEqual(l, [self.richard_id, self.mary_id]) | 963 self.assertEqual(l, [self.richard_id, self.mary_id]) |
| 963 return nodeid | 964 return nodeid |
| 964 | 965 |
| 966 | |
| 967 def testDejaVu(self): | |
| 968 self.assertRaises(IgnoreLoop, self._send_mail, | |
| 969 '''Content-Type: text/plain; | |
| 970 charset="iso-8859-1" | |
| 971 From: Chef <chef@bork.bork.bork> | |
| 972 X-Roundup-Loop: hello | |
| 973 To: issue_tracker@your.tracker.email.domain.example | |
| 974 Cc: richard@test | |
| 975 Message-Id: <dummy_test_message_id> | |
| 976 Subject: Re: [issue] Testing... | |
| 977 | |
| 978 Hi, I've been mis-configured to loop messages back to myself. | |
| 979 ''') | |
| 980 | |
| 981 def testItsBulkStupid(self): | |
| 982 self.assertRaises(IgnoreBulk, self._send_mail, | |
| 983 '''Content-Type: text/plain; | |
| 984 charset="iso-8859-1" | |
| 985 From: Chef <chef@bork.bork.bork> | |
| 986 Precedence: bulk | |
| 987 To: issue_tracker@your.tracker.email.domain.example | |
| 988 Cc: richard@test | |
| 989 Message-Id: <dummy_test_message_id> | |
| 990 Subject: Re: [issue] Testing... | |
| 991 | |
| 992 Hi, I'm on holidays, and this is a dumb auto-responder. | |
| 993 ''') | |
| 994 | |
| 965 def test_suite(): | 995 def test_suite(): |
| 966 suite = unittest.TestSuite() | 996 suite = unittest.TestSuite() |
| 967 suite.addTest(unittest.makeSuite(MailgwTestCase)) | 997 suite.addTest(unittest.makeSuite(MailgwTestCase)) |
| 968 return suite | 998 return suite |
| 969 | 999 |
