Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 699:676d4cfde9a5
Nosy list improvements.
. added option to automatically add the authors and recipients of messages
to the nosy lists with the options ADD_AUTHOR_TO_NOSY (default 'new') and
ADD_RECIPIENTS_TO_NOSY (default 'new'). These settings emulate the current
behaviour. Setting them to 'yes' will add the author/recipients to the nosy
on messages that create issues and followup messages.
. added missing documentation for a few of the config option values
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 02 May 2002 07:56:34 +0000 |
| parents | 4afa9be56dd3 |
| children | e10c37f53efd |
comparison
equal
deleted
inserted
replaced
| 698:a26afb64a947 | 699:676d4cfde9a5 |
|---|---|
| 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.16 2002-03-19 21:58:11 grubert Exp $ | 11 # $Id: test_mailgw.py,v 1.17 2002-05-02 07:56:34 richard Exp $ |
| 12 | 12 |
| 13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib | 13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib |
| 14 | 14 |
| 15 from roundup.mailgw import MailGW | 15 from roundup.mailgw import MailGW |
| 16 from roundup import init, instance | 16 from roundup import init, instance |
| 91 Subject: [issue] Testing... | 91 Subject: [issue] Testing... |
| 92 | 92 |
| 93 This is a test submission of a new issue. | 93 This is a test submission of a new issue. |
| 94 ''') | 94 ''') |
| 95 handler = self.instance.MailGW(self.instance, self.db) | 95 handler = self.instance.MailGW(self.instance, self.db) |
| 96 handler.main(message) | 96 nodeid = handler.main(message) |
| 97 if os.path.exists(os.environ['SENDMAILDEBUG']): | 97 if os.path.exists(os.environ['SENDMAILDEBUG']): |
| 98 error = open(os.environ['SENDMAILDEBUG']).read() | 98 error = open(os.environ['SENDMAILDEBUG']).read() |
| 99 self.assertEqual('no error', error) | 99 self.assertEqual('no error', error) |
| 100 self.assertEqual(self.db.issue.get(nodeid, 'nosy'), ['2', '3']) | |
| 101 | |
| 102 def testNewIssueNosy(self): | |
| 103 self.instance.ADD_AUTHOR_TO_NOSY = 'yes' | |
| 104 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 105 charset="iso-8859-1" | |
| 106 From: Chef <chef@bork.bork.bork | |
| 107 To: issue_tracker@fill.me.in. | |
| 108 Cc: richard@test | |
| 109 Message-Id: <dummy_test_message_id> | |
| 110 Subject: [issue] Testing... | |
| 111 | |
| 112 This is a test submission of a new issue. | |
| 113 ''') | |
| 114 handler = self.instance.MailGW(self.instance, self.db) | |
| 115 nodeid = handler.main(message) | |
| 116 if os.path.exists(os.environ['SENDMAILDEBUG']): | |
| 117 error = open(os.environ['SENDMAILDEBUG']).read() | |
| 118 self.assertEqual('no error', error) | |
| 119 self.assertEqual(self.db.issue.get(nodeid, 'nosy'), ['2', '3']) | |
| 100 | 120 |
| 101 def testAlternateAddress(self): | 121 def testAlternateAddress(self): |
| 102 message = cStringIO.StringIO('''Content-Type: text/plain; | 122 message = cStringIO.StringIO('''Content-Type: text/plain; |
| 103 charset="iso-8859-1" | 123 charset="iso-8859-1" |
| 104 From: John Doe <john.doe@test> | 124 From: John Doe <john.doe@test> |
| 319 "Roundup issue tracker" <issue_tracker@fill.me.in.> | 339 "Roundup issue tracker" <issue_tracker@fill.me.in.> |
| 320 http://some.useful.url/issue1 | 340 http://some.useful.url/issue1 |
| 321 ___________________________________________________ | 341 ___________________________________________________ |
| 322 ''') | 342 ''') |
| 323 | 343 |
| 344 def testFollowupNosyAuthor(self): | |
| 345 self.testNewIssue() | |
| 346 self.instance.ADD_AUTHOR_TO_NOSY = 'yes' | |
| 347 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 348 charset="iso-8859-1" | |
| 349 From: john@test | |
| 350 To: issue_tracker@fill.me.in. | |
| 351 Message-Id: <followup_dummy_id> | |
| 352 In-Reply-To: <dummy_test_message_id> | |
| 353 Subject: [issue1] Testing... | |
| 354 | |
| 355 This is a followup | |
| 356 ''') | |
| 357 handler = self.instance.MailGW(self.instance, self.db) | |
| 358 handler.main(message) | |
| 359 | |
| 360 self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(), | |
| 361 '''FROM: roundup-admin@fill.me.in. | |
| 362 TO: chef@bork.bork.bork, richard@test | |
| 363 Content-Type: text/plain | |
| 364 Subject: [issue1] Testing... | |
| 365 To: chef@bork.bork.bork, richard@test | |
| 366 From: john <issue_tracker@fill.me.in.> | |
| 367 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> | |
| 368 MIME-Version: 1.0 | |
| 369 Message-Id: <followup_dummy_id> | |
| 370 In-Reply-To: <dummy_test_message_id> | |
| 371 X-Roundup-Name: Roundup issue tracker | |
| 372 Content-Transfer-Encoding: quoted-printable | |
| 373 | |
| 374 | |
| 375 john <john@test> added the comment: | |
| 376 | |
| 377 This is a followup | |
| 378 | |
| 379 | |
| 380 ---------- | |
| 381 nosy: +john | |
| 382 status: unread -> chatting | |
| 383 ___________________________________________________ | |
| 384 "Roundup issue tracker" <issue_tracker@fill.me.in.> | |
| 385 http://some.useful.url/issue1 | |
| 386 ___________________________________________________ | |
| 387 | |
| 388 ''') | |
| 389 | |
| 390 def testFollowupNosyRecipients(self): | |
| 391 self.testNewIssue() | |
| 392 self.instance.ADD_RECIPIENTS_TO_NOSY = 'yes' | |
| 393 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 394 charset="iso-8859-1" | |
| 395 From: richard@test | |
| 396 To: issue_tracker@fill.me.in. | |
| 397 Cc: john@test | |
| 398 Message-Id: <followup_dummy_id> | |
| 399 In-Reply-To: <dummy_test_message_id> | |
| 400 Subject: [issue1] Testing... | |
| 401 | |
| 402 This is a followup | |
| 403 ''') | |
| 404 handler = self.instance.MailGW(self.instance, self.db) | |
| 405 handler.main(message) | |
| 406 | |
| 407 self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(), | |
| 408 '''FROM: roundup-admin@fill.me.in. | |
| 409 TO: chef@bork.bork.bork | |
| 410 Content-Type: text/plain | |
| 411 Subject: [issue1] Testing... | |
| 412 To: chef@bork.bork.bork | |
| 413 From: richard <issue_tracker@fill.me.in.> | |
| 414 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> | |
| 415 MIME-Version: 1.0 | |
| 416 Message-Id: <followup_dummy_id> | |
| 417 In-Reply-To: <dummy_test_message_id> | |
| 418 X-Roundup-Name: Roundup issue tracker | |
| 419 Content-Transfer-Encoding: quoted-printable | |
| 420 | |
| 421 | |
| 422 richard <richard@test> added the comment: | |
| 423 | |
| 424 This is a followup | |
| 425 | |
| 426 | |
| 427 ---------- | |
| 428 nosy: +john | |
| 429 status: unread -> chatting | |
| 430 ___________________________________________________ | |
| 431 "Roundup issue tracker" <issue_tracker@fill.me.in.> | |
| 432 http://some.useful.url/issue1 | |
| 433 ___________________________________________________ | |
| 434 | |
| 435 ''') | |
| 436 | |
| 437 def testFollowupNosyAuthorAndCopy(self): | |
| 438 self.testNewIssue() | |
| 439 self.instance.ADD_AUTHOR_TO_NOSY = 'yes' | |
| 440 self.db.config.MESSAGES_TO_AUTHOR = 'yes' | |
| 441 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 442 charset="iso-8859-1" | |
| 443 From: john@test | |
| 444 To: issue_tracker@fill.me.in. | |
| 445 Message-Id: <followup_dummy_id> | |
| 446 In-Reply-To: <dummy_test_message_id> | |
| 447 Subject: [issue1] Testing... | |
| 448 | |
| 449 This is a followup | |
| 450 ''') | |
| 451 handler = self.instance.MailGW(self.instance, self.db) | |
| 452 handler.main(message) | |
| 453 | |
| 454 self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(), | |
| 455 '''FROM: roundup-admin@fill.me.in. | |
| 456 TO: john@test, chef@bork.bork.bork, richard@test | |
| 457 Content-Type: text/plain | |
| 458 Subject: [issue1] Testing... | |
| 459 To: john@test, chef@bork.bork.bork, richard@test | |
| 460 From: john <issue_tracker@fill.me.in.> | |
| 461 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> | |
| 462 MIME-Version: 1.0 | |
| 463 Message-Id: <followup_dummy_id> | |
| 464 In-Reply-To: <dummy_test_message_id> | |
| 465 X-Roundup-Name: Roundup issue tracker | |
| 466 Content-Transfer-Encoding: quoted-printable | |
| 467 | |
| 468 | |
| 469 john <john@test> added the comment: | |
| 470 | |
| 471 This is a followup | |
| 472 | |
| 473 | |
| 474 ---------- | |
| 475 nosy: +john | |
| 476 status: unread -> chatting | |
| 477 ___________________________________________________ | |
| 478 "Roundup issue tracker" <issue_tracker@fill.me.in.> | |
| 479 http://some.useful.url/issue1 | |
| 480 ___________________________________________________ | |
| 481 | |
| 482 ''') | |
| 483 | |
| 484 def testFollowupNoNosyAuthor(self): | |
| 485 self.testNewIssue() | |
| 486 self.instance.ADD_AUTHOR_TO_NOSY = 'no' | |
| 487 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 488 charset="iso-8859-1" | |
| 489 From: john@test | |
| 490 To: issue_tracker@fill.me.in. | |
| 491 Message-Id: <followup_dummy_id> | |
| 492 In-Reply-To: <dummy_test_message_id> | |
| 493 Subject: [issue1] Testing... | |
| 494 | |
| 495 This is a followup | |
| 496 ''') | |
| 497 handler = self.instance.MailGW(self.instance, self.db) | |
| 498 handler.main(message) | |
| 499 | |
| 500 self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(), | |
| 501 '''FROM: roundup-admin@fill.me.in. | |
| 502 TO: chef@bork.bork.bork, richard@test | |
| 503 Content-Type: text/plain | |
| 504 Subject: [issue1] Testing... | |
| 505 To: chef@bork.bork.bork, richard@test | |
| 506 From: john <issue_tracker@fill.me.in.> | |
| 507 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> | |
| 508 MIME-Version: 1.0 | |
| 509 Message-Id: <followup_dummy_id> | |
| 510 In-Reply-To: <dummy_test_message_id> | |
| 511 X-Roundup-Name: Roundup issue tracker | |
| 512 Content-Transfer-Encoding: quoted-printable | |
| 513 | |
| 514 | |
| 515 john <john@test> added the comment: | |
| 516 | |
| 517 This is a followup | |
| 518 | |
| 519 | |
| 520 ---------- | |
| 521 status: unread -> chatting | |
| 522 ___________________________________________________ | |
| 523 "Roundup issue tracker" <issue_tracker@fill.me.in.> | |
| 524 http://some.useful.url/issue1 | |
| 525 ___________________________________________________ | |
| 526 | |
| 527 ''') | |
| 528 | |
| 529 def testFollowupNoNosyRecipients(self): | |
| 530 self.testNewIssue() | |
| 531 self.instance.ADD_RECIPIENTS_TO_NOSY = 'no' | |
| 532 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 533 charset="iso-8859-1" | |
| 534 From: richard@test | |
| 535 To: issue_tracker@fill.me.in. | |
| 536 Cc: john@test | |
| 537 Message-Id: <followup_dummy_id> | |
| 538 In-Reply-To: <dummy_test_message_id> | |
| 539 Subject: [issue1] Testing... | |
| 540 | |
| 541 This is a followup | |
| 542 ''') | |
| 543 handler = self.instance.MailGW(self.instance, self.db) | |
| 544 handler.main(message) | |
| 545 | |
| 546 self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(), | |
| 547 '''FROM: roundup-admin@fill.me.in. | |
| 548 TO: chef@bork.bork.bork | |
| 549 Content-Type: text/plain | |
| 550 Subject: [issue1] Testing... | |
| 551 To: chef@bork.bork.bork | |
| 552 From: richard <issue_tracker@fill.me.in.> | |
| 553 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> | |
| 554 MIME-Version: 1.0 | |
| 555 Message-Id: <followup_dummy_id> | |
| 556 In-Reply-To: <dummy_test_message_id> | |
| 557 X-Roundup-Name: Roundup issue tracker | |
| 558 Content-Transfer-Encoding: quoted-printable | |
| 559 | |
| 560 | |
| 561 richard <richard@test> added the comment: | |
| 562 | |
| 563 This is a followup | |
| 564 | |
| 565 | |
| 566 ---------- | |
| 567 status: unread -> chatting | |
| 568 ___________________________________________________ | |
| 569 "Roundup issue tracker" <issue_tracker@fill.me.in.> | |
| 570 http://some.useful.url/issue1 | |
| 571 ___________________________________________________ | |
| 572 | |
| 573 ''') | |
| 574 | |
| 324 def testEnc01(self): | 575 def testEnc01(self): |
| 325 self.testNewIssue() | 576 self.testNewIssue() |
| 326 message = cStringIO.StringIO('''Content-Type: text/plain; | 577 message = cStringIO.StringIO('''Content-Type: text/plain; |
| 327 charset="iso-8859-1" | 578 charset="iso-8859-1" |
| 328 From: mary <mary@test> | 579 From: mary <mary@test> |
| 421 | 672 |
| 422 class ExtMailgwTestCase(MailgwTestCase): | 673 class ExtMailgwTestCase(MailgwTestCase): |
| 423 schema = 'extended' | 674 schema = 'extended' |
| 424 | 675 |
| 425 def suite(): | 676 def suite(): |
| 426 l = [unittest.makeSuite(MailgwTestCase, 'test'), | 677 l = [unittest.makeSuite(MailgwTestCase), |
| 427 # unittest.makeSuite(ExtMailgwTestCase, 'test') | 678 unittest.makeSuite(ExtMailgwTestCase, 'test') |
| 428 ] | 679 ] |
| 429 return unittest.TestSuite(l) | 680 return unittest.TestSuite(l) |
| 430 | 681 |
| 431 | 682 |
| 432 # | 683 # |
| 433 # $Log: not supported by cvs2svn $ | 684 # $Log: not supported by cvs2svn $ |
| 685 # Revision 1.16 2002/03/19 21:58:11 grubert | |
| 686 # . for python2.1 test_mailgw compareString allows an extra trailing empty line (for quopri. | |
| 687 # | |
| 434 # Revision 1.15 2002/03/19 06:37:00 richard | 688 # Revision 1.15 2002/03/19 06:37:00 richard |
| 435 # Made the email checking spit out a diff - much easier to spot the problem! | 689 # Made the email checking spit out a diff - much easier to spot the problem! |
| 436 # | 690 # |
| 437 # Revision 1.14 2002/03/18 18:32:00 rochecompaan | 691 # Revision 1.14 2002/03/18 18:32:00 rochecompaan |
| 438 # All messages sent to the nosy list are now encoded as quoted-printable. | 692 # All messages sent to the nosy list are now encoded as quoted-printable. |
