|
8 | 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10 | 10 | # |
11 | | -# $Id: test_mailgw.py,v 1.69 2004-04-20 21:55:45 richard Exp $ |
| 11 | +# $Id: test_mailgw.py,v 1.70 2004-09-29 08:05:33 a1s Exp $ |
12 | 12 |
|
13 | 13 | # TODO: test bcc |
14 | 14 |
|
|
22 | 22 |
|
23 | 23 | from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \ |
24 | 24 | parseContent, IgnoreLoop, IgnoreBulk |
25 | | -from roundup import init, instance, rfc2822, __version__ |
| 25 | +from roundup import init, instance, password, rfc2822, __version__ |
26 | 26 |
|
27 | 27 |
|
28 | 28 | class Message(rfc822.Message): |
29 | 29 | """String-based Message class with equivalence test.""" |
30 | 30 | def __init__(self, s): |
31 | 31 | rfc822.Message.__init__(self, StringIO(s.strip())) |
32 | | - |
| 32 | + |
33 | 33 | def __eq__(self, other): |
34 | 34 | return (self.dict == other.dict and |
35 | | - self.fp.read() == other.fp.read()) |
| 35 | + self.fp.read() == other.fp.read()) |
36 | 36 |
|
37 | 37 | class DiffHelper: |
38 | 38 | def compareMessages(self, new, old): |
@@ -60,7 +60,7 @@ def compareMessages(self, new, old): |
60 | 60 | if res: |
61 | 61 | res.insert(0, 'Generated message not correct (diff follows):') |
62 | 62 | raise AssertionError, '\n'.join(res) |
63 | | - |
| 63 | + |
64 | 64 | def compareStrings(self, s2, s1): |
65 | 65 | '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants |
66 | 66 | the first to be the "original" but in the calls in this file, |
@@ -102,10 +102,10 @@ def setUp(self): |
102 | 102 | # create the instance |
103 | 103 | init.install(self.dirname, 'templates/classic') |
104 | 104 | init.write_select_db(self.dirname, 'anydbm') |
105 | | - init.initialise(self.dirname, 'sekrit') |
106 | | - |
107 | | - # check we can load the package |
108 | | - self.instance = instance.open(self.dirname) |
| 105 | + self.instance = tracker = instance.open(self.dirname) |
| 106 | + if tracker.exists(): |
| 107 | + tracker.nuke() |
| 108 | + tracker.init(password.Password('sekrit')) |
109 | 109 |
|
110 | 110 | # and open the database |
111 | 111 | self.db = self.instance.open('admin') |
@@ -135,7 +135,7 @@ def _handle_mail(self, message): |
135 | 135 | # handler can close the db on us and open a new one |
136 | 136 | self.db = handler.db |
137 | 137 | return ret |
138 | | - |
| 138 | + |
139 | 139 | def _get_mail(self): |
140 | 140 | f = open(SENDMAILDEBUG) |
141 | 141 | try: |
@@ -204,7 +204,7 @@ def testAlternateAddress(self): |
204 | 204 |
|
205 | 205 | This is a test submission of a new issue. |
206 | 206 | ''') |
207 | | - userlist = self.db.user.list() |
| 207 | + userlist = self.db.user.list() |
208 | 208 | assert not os.path.exists(SENDMAILDEBUG) |
209 | 209 | self.assertEqual(userlist, self.db.user.list(), |
210 | 210 | "user created when it shouldn't have been") |
@@ -271,7 +271,7 @@ def testNewIssueAuthMsg(self): |
271 | 271 | # '''With more than one part''' |
272 | 272 | # see MultipartEnc tests: but if there is more than one part |
273 | 273 | # we return a multipart/mixed and the boundary contains |
274 | | - # the ip address of the test machine. |
| 274 | + # the ip address of the test machine. |
275 | 275 |
|
276 | 276 | # BUG should test some binary attamchent too. |
277 | 277 |
|
@@ -808,21 +808,21 @@ def testContentDisposition(self): |
808 | 808 | Message-Id: <followup_dummy_id> |
809 | 809 | In-Reply-To: <dummy_test_message_id> |
810 | 810 | Subject: [issue1] Testing... |
811 | | -Content-Type: multipart/mixed; boundary="bCsyhTFzCvuiizWE" |
812 | | -Content-Disposition: inline |
813 | | - |
814 | | - |
815 | | ---bCsyhTFzCvuiizWE |
816 | | -Content-Type: text/plain; charset=us-ascii |
817 | | -Content-Disposition: inline |
| 811 | +Content-Type: multipart/mixed; boundary="bCsyhTFzCvuiizWE" |
| 812 | +Content-Disposition: inline |
818 | 813 |
|
819 | | -test attachment binary |
820 | 814 |
|
821 | | ---bCsyhTFzCvuiizWE |
822 | | -Content-Type: application/octet-stream |
823 | | -Content-Disposition: attachment; filename="main.dvi" |
| 815 | +--bCsyhTFzCvuiizWE |
| 816 | +Content-Type: text/plain; charset=us-ascii |
| 817 | +Content-Disposition: inline |
824 | 818 |
|
825 | | -xxxxxx |
| 819 | +test attachment binary |
| 820 | +
|
| 821 | +--bCsyhTFzCvuiizWE |
| 822 | +Content-Type: application/octet-stream |
| 823 | +Content-Disposition: attachment; filename="main.dvi" |
| 824 | +
|
| 825 | +xxxxxx |
826 | 826 |
|
827 | 827 | --bCsyhTFzCvuiizWE-- |
828 | 828 | ''') |
@@ -967,7 +967,7 @@ def testFollowupOnNonIssue(self): |
967 | 967 | In-Reply-To: <dummy_test_message_id> |
968 | 968 | Subject: [keyword1] Testing... [name=Bar] |
969 | 969 |
|
970 | | -''') |
| 970 | +''') |
971 | 971 | self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') |
972 | 972 |
|
973 | 973 | def testResentFrom(self): |
@@ -1026,4 +1026,4 @@ def test_suite(): |
1026 | 1026 | runner = unittest.TextTestRunner() |
1027 | 1027 | unittest.main(testRunner=runner) |
1028 | 1028 |
|
1029 | | -# vim: set filetype=python ts=4 sw=4 et si |
| 1029 | +# vim: set filetype=python sts=4 sw=4 et si : |
0 commit comments