summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 948d7b2)
raw | patch | inline | side by side (parent: 948d7b2)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 20 Jan 2004 00:11:51 +0000 (00:11 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 20 Jan 2004 00:11:51 +0000 (00:11 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2052 57a73879-2fb5-44c3-a270-3262357dd7e2
test/test_mailgw.py | patch | blob | history |
diff --git a/test/test_mailgw.py b/test/test_mailgw.py
index bf8c440b614dd3c4994c9b95f8657ebc4453a067..aebded9b1c4c07e6fe64d1e2538c474bea5b3434 100644 (file)
--- a/test/test_mailgw.py
+++ b/test/test_mailgw.py
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: test_mailgw.py,v 1.63 2003-12-04 23:34:25 richard Exp $
+# $Id: test_mailgw.py,v 1.64 2004-01-20 00:11:51 richard Exp $
import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \
parseContent, IgnoreLoop, IgnoreBulk
-from roundup import init, instance, rfc2822
+from roundup import init, instance, rfc2822, __version__
class Message(rfc822.Message):
del new['date'], old['date']
if not new == old:
- res = ['Generated message not correct (diff follows):']
+ res = []
for key in new.keys():
- if new[key] != old[key]:
+ if key.lower() == 'x-roundup-version':
+ # version changes constantly, so handle it specially
+ if new[key] != __version__:
+ res.append(' %s: %s != %s' % (key, __version__,
+ new[key]))
+ elif new[key] != old[key]:
res.append(' %s: %s != %s' % (key, old[key], new[key]))
-
+
body_diff = self.compareStrings(new.fp.read(), old.fp.read())
if body_diff:
res.append('')
res.extend(body_diff)
- raise AssertionError, '\n'.join(res)
+ if res:
+ res.insert(0, 'Generated message not correct (diff follows):')
+ raise AssertionError, '\n'.join(res)
def compareStrings(self, s2, s1):
'''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants
except OSError, error:
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
- def _send_mail(self, message):
+ def _handle_mail(self, message):
handler = self.instance.MailGW(self.instance, self.db)
handler.trapExceptions = 0
return handler.main(StringIO(message))
f.close()
def testEmptyMessage(self):
- nodeid = self._send_mail('''Content-Type: text/plain;
+ nodeid = self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
To: issue_tracker@your.tracker.email.domain.example
Cc: richard@test
+Reply-To: chef@bork.bork.bork
Message-Id: <dummy_test_message_id>
Subject: [issue] Testing...
self.assertEqual(self.db.issue.get(nodeid, 'title'), 'Testing...')
def doNewIssue(self):
- nodeid = self._send_mail('''Content-Type: text/plain;
+ nodeid = self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
To: issue_tracker@your.tracker.email.domain.example
def testNewIssueNosy(self):
self.instance.config.ADD_AUTHOR_TO_NOSY = 'yes'
- nodeid = self._send_mail('''Content-Type: text/plain;
+ nodeid = self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
To: issue_tracker@your.tracker.email.domain.example
self.assertEqual(l, [self.chef_id, self.richard_id])
def testAlternateAddress(self):
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: John Doe <john.doe@test>
To: issue_tracker@your.tracker.email.domain.example
"user created when it shouldn't have been")
def testNewIssueNoClass(self):
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
To: issue_tracker@your.tracker.email.domain.example
def testNewIssueAuthMsg(self):
# TODO: fix the damn config - this is apalling
self.db.config.MESSAGES_TO_AUTHOR = 'yes'
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
To: issue_tracker@your.tracker.email.domain.example
def testSimpleFollowup(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: mary <mary@test>
To: issue_tracker@your.tracker.email.domain.example
def testFollowup(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
def testFollowupTitleMatch(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
def testFollowupNosyAuthor(self):
self.doNewIssue()
self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: john@test
To: issue_tracker@your.tracker.email.domain.example
def testFollowupNosyRecipients(self):
self.doNewIssue()
self.db.config.ADD_RECIPIENTS_TO_NOSY = 'yes'
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard@test
To: issue_tracker@your.tracker.email.domain.example
self.doNewIssue()
self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
self.db.config.MESSAGES_TO_AUTHOR = 'yes'
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: john@test
To: issue_tracker@your.tracker.email.domain.example
def testFollowupNoNosyAuthor(self):
self.doNewIssue()
self.instance.config.ADD_AUTHOR_TO_NOSY = 'no'
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: john@test
To: issue_tracker@your.tracker.email.domain.example
def testFollowupNoNosyRecipients(self):
self.doNewIssue()
self.instance.config.ADD_RECIPIENTS_TO_NOSY = 'no'
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard@test
To: issue_tracker@your.tracker.email.domain.example
def testFollowupEmptyMessage(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
def testNosyRemove(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
This is a test submission of a new issue.
'''
- self.assertRaises(Unauthorized, self._send_mail, message)
+ self.assertRaises(Unauthorized, self._handle_mail, message)
m = self.db.user.list()
m.sort()
self.assertEqual(l, m)
# now with the permission
p = self.db.security.getPermission('Email Registration')
self.db.security.role['anonymous'].permissions=[p]
- self._send_mail(message)
+ self._handle_mail(message)
m = self.db.user.list()
m.sort()
self.assertNotEqual(l, m)
def testEnc01(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: mary <mary@test>
To: issue_tracker@your.tracker.email.domain.example
def testMultipartEnc01(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: mary <mary@test>
To: issue_tracker@your.tracker.email.domain.example
def testContentDisposition(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: mary <mary@test>
To: issue_tracker@your.tracker.email.domain.example
def testFollowupStupidQuoting(self):
self.doNewIssue()
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
messages = self.db.issue.get(nodeid, 'messages')
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
def testRegistrationConfirmation(self):
otk = "Aj4euk4LZSAdwePohj90SME5SpopLETL"
self.db.otks.set(otk, username='johannes', __time='')
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
To: issue_tracker@your.tracker.email.domain.example
def testFollowupOnNonIssue(self):
self.db.keyword.create(name='Foo')
- self._send_mail('''Content-Type: text/plain;
+ self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: richard <richard@test>
To: issue_tracker@your.tracker.email.domain.example
self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar')
def testResentFrom(self):
- nodeid = self._send_mail('''Content-Type: text/plain;
+ nodeid = self._handle_mail('''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
Resent-From: mary <mary@test>
def testDejaVu(self):
- self.assertRaises(IgnoreLoop, self._send_mail,
+ self.assertRaises(IgnoreLoop, self._handle_mail,
'''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>
''')
def testItsBulkStupid(self):
- self.assertRaises(IgnoreBulk, self._send_mail,
+ self.assertRaises(IgnoreBulk, self._handle_mail,
'''Content-Type: text/plain;
charset="iso-8859-1"
From: Chef <chef@bork.bork.bork>