Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 4350:23bf9290140a
don't have mailgw tests close the db - they're not testing persistence
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 08 Feb 2010 08:30:37 +0000 |
| parents | 7a0fe3cff4de |
| children | 887a153cedec |
comparison
equal
deleted
inserted
replaced
| 4349:f0faef4dd023 | 4350:23bf9290140a |
|---|---|
| 141 def tearDown(self): | 141 def tearDown(self): |
| 142 if os.path.exists(SENDMAILDEBUG): | 142 if os.path.exists(SENDMAILDEBUG): |
| 143 os.remove(SENDMAILDEBUG) | 143 os.remove(SENDMAILDEBUG) |
| 144 self.db.close() | 144 self.db.close() |
| 145 | 145 |
| 146 def _create_mailgw(self, message): | |
| 147 class MailGW(self.instance.MailGW): | |
| 148 def handle_message(self, message): | |
| 149 return self._handle_message(message) | |
| 150 handler = MailGW(self.instance) | |
| 151 handler.db = self.db | |
| 152 return handler | |
| 153 | |
| 146 def _handle_mail(self, message): | 154 def _handle_mail(self, message): |
| 147 handler = self.instance.MailGW(self.instance) | 155 handler = self._create_mailgw(message) |
| 148 handler.trapExceptions = 0 | 156 handler.trapExceptions = 0 |
| 149 return handler.main(StringIO(message)) | 157 return handler.main(StringIO(message)) |
| 150 | 158 |
| 151 def _get_mail(self): | 159 def _get_mail(self): |
| 152 f = open(SENDMAILDEBUG) | 160 f = open(SENDMAILDEBUG) |
| 580 oldvalues = self.db.getnode('issue', '1').copy() | 588 oldvalues = self.db.getnode('issue', '1').copy() |
| 581 oldvalues['assignedto'] = None | 589 oldvalues['assignedto'] = None |
| 582 # reconstruct old behaviour: This would reuse the | 590 # reconstruct old behaviour: This would reuse the |
| 583 # database-handle from the doNewIssue above which has committed | 591 # database-handle from the doNewIssue above which has committed |
| 584 # as user "Chef". So we close and reopen the db as that user. | 592 # as user "Chef". So we close and reopen the db as that user. |
| 585 self.db.close() | 593 #self.db.close() actually don't close 'cos this empties memorydb |
| 586 self.db = self.instance.open('Chef') | 594 self.db = self.instance.open('Chef') |
| 587 self.db.issue.set('1', assignedto=self.chef_id) | 595 self.db.issue.set('1', assignedto=self.chef_id) |
| 588 self.db.commit() | 596 self.db.commit() |
| 589 self.db.issue.nosymessage('1', None, oldvalues) | 597 self.db.issue.nosymessage('1', None, oldvalues) |
| 590 | 598 |
| 1030 | 1038 |
| 1031 # NO NOSY MESSAGE SHOULD BE SENT! | 1039 # NO NOSY MESSAGE SHOULD BE SENT! |
| 1032 assert not os.path.exists(SENDMAILDEBUG) | 1040 assert not os.path.exists(SENDMAILDEBUG) |
| 1033 | 1041 |
| 1034 def testNewUserAuthor(self): | 1042 def testNewUserAuthor(self): |
| 1043 self.db.commit() | |
| 1035 l = self.db.user.list() | 1044 l = self.db.user.list() |
| 1036 l.sort() | 1045 l.sort() |
| 1037 message = '''Content-Type: text/plain; | 1046 message = '''Content-Type: text/plain; |
| 1038 charset="iso-8859-1" | 1047 charset="iso-8859-1" |
| 1039 From: fubar <fubar@bork.bork.bork> | 1048 From: fubar <fubar@bork.bork.bork> |
| 1131 Message-Id: <dummy_test_message_id> | 1140 Message-Id: <dummy_test_message_id> |
| 1132 Subject: [issue] Testing nonexisting user... | 1141 Subject: [issue] Testing nonexisting user... |
| 1133 | 1142 |
| 1134 This is a test submission of a new issue. | 1143 This is a test submission of a new issue. |
| 1135 ''' | 1144 ''' |
| 1136 self.db.close() | 1145 handler = self._create_mailgw(message) |
| 1137 handler = self.instance.MailGW(self.instance) | |
| 1138 # we want a bounce message: | 1146 # we want a bounce message: |
| 1139 handler.trapExceptions = 1 | 1147 handler.trapExceptions = 1 |
| 1140 ret = handler.main(StringIO(message)) | 1148 ret = handler.main(StringIO(message)) |
| 1141 self.compareMessages(self._get_mail(), | 1149 self.compareMessages(self._get_mail(), |
| 1142 '''FROM: Roundup issue tracker <roundup-admin@your.tracker.email.domain.example> | 1150 '''FROM: Roundup issue tracker <roundup-admin@your.tracker.email.domain.example> |
