X-Git-Url: https://git.tokkee.org/?p=roundup.git;a=blobdiff_plain;f=test%2Ftest_mailgw.py;fp=test%2Ftest_mailgw.py;h=9c3936c3f6c2062b3a344b2b28aa64a2d2c2d9cd;hp=fde8c460c3846d3bf2ce9403a619b4c6e69c26d2;hb=2f96d56d70616ba2df4acd5a5fea456d28286846;hpb=9976de4f1761b47dc459f10c4b28c311de84e103 diff --git a/test/test_mailgw.py b/test/test_mailgw.py index fde8c46..9c3936c 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -290,8 +290,7 @@ Hi there! self.assertEqual(self.db.issue.get(nodeid, 'status'), '3') self.assertEqual(self.db.issue.get(nodeid, 'priority'), '1') - def doNewIssue(self): - nodeid = self._handle_mail('''Content-Type: text/plain; + newmsg = '''Content-Type: text/plain; charset="iso-8859-1" From: Chef To: issue_tracker@your.tracker.email.domain.example @@ -300,7 +299,10 @@ Message-Id: Subject: [issue] Testing... This is a test submission of a new issue. -''') +''' + + def doNewIssue(self): + nodeid = self._handle_mail(self.newmsg) assert not os.path.exists(SENDMAILDEBUG) l = self.db.issue.get(nodeid, 'nosy') l.sort() @@ -312,20 +314,25 @@ This is a test submission of a new issue. def testNewIssueNosy(self): self.instance.config.ADD_AUTHOR_TO_NOSY = 'yes' - nodeid = self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" -From: Chef -To: issue_tracker@your.tracker.email.domain.example -Cc: richard@test.test -Message-Id: -Subject: [issue] Testing... + nodeid = self.doNewIssue() + m = self.db.issue.get(nodeid, 'messages') + self.assertEqual(len(m), 1) + recv = self.db.msg.get(m[0], 'recipients') + self.assertEqual(recv, [self.richard_id]) -This is a test submission of a new issue. -''') + def testNewIssueNosyAuthor(self): + self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' + self.instance.config.MESSAGES_TO_AUTHOR = 'nosy' + nodeid = self._handle_mail(self.newmsg) assert not os.path.exists(SENDMAILDEBUG) l = self.db.issue.get(nodeid, 'nosy') l.sort() - self.assertEqual(l, [self.chef_id, self.richard_id]) + self.assertEqual(l, [self.richard_id]) + m = self.db.issue.get(nodeid, 'messages') + self.assertEqual(len(m), 1) + recv = self.db.msg.get(m[0], 'recipients') + recv.sort() + self.assertEqual(recv, [self.richard_id]) def testAlternateAddress(self): self._handle_mail('''Content-Type: text/plain; @@ -356,7 +363,6 @@ This is a test submission of a new issue. assert not os.path.exists(SENDMAILDEBUG) def testNewIssueAuthMsg(self): - # TODO: fix the damn config - this is apalling self.db.config.MESSAGES_TO_AUTHOR = 'yes' self._handle_mail('''Content-Type: text/plain; charset="iso-8859-1" @@ -1453,11 +1459,7 @@ Subject: Re: Testing... This is a followup '''), nodeid) - - def testFollowupNosyAuthor(self): - self.doNewIssue() - self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' - self._handle_mail('''Content-Type: text/plain; + simple_followup = '''Content-Type: text/plain; charset="iso-8859-1" From: john@test.test To: issue_tracker@your.tracker.email.domain.example @@ -1466,8 +1468,12 @@ In-Reply-To: Subject: [issue1] Testing... This is a followup -''') +''' + def testFollowupNosyAuthor(self): + self.doNewIssue() + self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' + self._handle_mail(self.simple_followup) self.compareMessages(self._get_mail(), '''FROM: roundup-admin@your.tracker.email.domain.example TO: chef@bork.bork.bork, richard@test.test @@ -1505,7 +1511,7 @@ _______________________________________________________________________ self.doNewIssue() self.db.config.ADD_RECIPIENTS_TO_NOSY = 'yes' self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" + charset="iso-8859-1" From: richard@test.test To: issue_tracker@your.tracker.email.domain.example Cc: john@test.test @@ -1552,16 +1558,45 @@ _______________________________________________________________________ self.doNewIssue() self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' self.db.config.MESSAGES_TO_AUTHOR = 'yes' - self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" -From: john@test.test -To: issue_tracker@your.tracker.email.domain.example + self._handle_mail(self.simple_followup) + self.compareMessages(self._get_mail(), +'''FROM: roundup-admin@your.tracker.email.domain.example +TO: chef@bork.bork.bork, john@test.test, richard@test.test +Content-Type: text/plain; charset="utf-8" +Subject: [issue1] Testing... +To: chef@bork.bork.bork, john@test.test, richard@test.test +From: John Doe +Reply-To: Roundup issue tracker + +MIME-Version: 1.0 Message-Id: In-Reply-To: -Subject: [issue1] Testing... +X-Roundup-Name: Roundup issue tracker +X-Roundup-Loop: hello +X-Roundup-Issue-Status: chatting +Content-Transfer-Encoding: quoted-printable + + +John Doe added the comment: This is a followup + +---------- +nosy: +john +status: unread -> chatting + +_______________________________________________________________________ +Roundup issue tracker + +_______________________________________________________________________ + ''') + + def testFollowupNosyAuthorNosyCopy(self): + self.doNewIssue() + self.db.config.ADD_AUTHOR_TO_NOSY = 'yes' + self.db.config.MESSAGES_TO_AUTHOR = 'nosy' + self._handle_mail(self.simple_followup) self.compareMessages(self._get_mail(), '''FROM: roundup-admin@your.tracker.email.domain.example TO: chef@bork.bork.bork, john@test.test, richard@test.test @@ -1598,16 +1633,44 @@ _______________________________________________________________________ def testFollowupNoNosyAuthor(self): self.doNewIssue() self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' - self._handle_mail('''Content-Type: text/plain; - charset="iso-8859-1" -From: john@test.test -To: issue_tracker@your.tracker.email.domain.example + self._handle_mail(self.simple_followup) + self.compareMessages(self._get_mail(), +'''FROM: roundup-admin@your.tracker.email.domain.example +TO: chef@bork.bork.bork, richard@test.test +Content-Type: text/plain; charset="utf-8" +Subject: [issue1] Testing... +To: chef@bork.bork.bork, richard@test.test +From: John Doe +Reply-To: Roundup issue tracker + +MIME-Version: 1.0 Message-Id: In-Reply-To: -Subject: [issue1] Testing... +X-Roundup-Name: Roundup issue tracker +X-Roundup-Loop: hello +X-Roundup-Issue-Status: chatting +Content-Transfer-Encoding: quoted-printable + + +John Doe added the comment: This is a followup + +---------- +status: unread -> chatting + +_______________________________________________________________________ +Roundup issue tracker + +_______________________________________________________________________ + ''') + + def testFollowupNoNosyAuthorNoCopy(self): + self.doNewIssue() + self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' + self.instance.config.MESSAGES_TO_AUTHOR = 'nosy' + self._handle_mail(self.simple_followup) self.compareMessages(self._get_mail(), '''FROM: roundup-admin@your.tracker.email.domain.example TO: chef@bork.bork.bork, richard@test.test @@ -1626,6 +1689,45 @@ X-Roundup-Issue-Status: chatting Content-Transfer-Encoding: quoted-printable +John Doe added the comment: + +This is a followup + +---------- +status: unread -> chatting + +_______________________________________________________________________ +Roundup issue tracker + +_______________________________________________________________________ + +''') + + # this is a pathological case where the author is *not* on the nosy + # list but gets the message; test documents existing behaviour + def testFollowupNoNosyAuthorButCopy(self): + self.doNewIssue() + self.instance.config.ADD_AUTHOR_TO_NOSY = 'no' + self.instance.config.MESSAGES_TO_AUTHOR = 'yes' + self._handle_mail(self.simple_followup) + self.compareMessages(self._get_mail(), +'''FROM: roundup-admin@your.tracker.email.domain.example +TO: chef@bork.bork.bork, john@test.test, richard@test.test +Content-Type: text/plain; charset="utf-8" +Subject: [issue1] Testing... +To: chef@bork.bork.bork, john@test.test, richard@test.test +From: John Doe +Reply-To: Roundup issue tracker + +MIME-Version: 1.0 +Message-Id: +In-Reply-To: +X-Roundup-Name: Roundup issue tracker +X-Roundup-Loop: hello +X-Roundup-Issue-Status: chatting +Content-Transfer-Encoding: quoted-printable + + John Doe added the comment: This is a followup