Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 1592:4074e2336eed
fixes to unit tests for recent changes
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 17 Apr 2003 06:51:44 +0000 |
| parents | 54f7717ece32 |
| children | fc9dafcb62e0 |
comparison
equal
deleted
inserted
replaced
| 1591:21312a7564fd | 1592:4074e2336eed |
|---|---|
| 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.43 2003-04-10 05:11:58 richard Exp $ | 11 # $Id: test_mailgw.py,v 1.44 2003-04-17 06:51:44 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 import rfc822 | 14 import rfc822 |
| 15 | 15 |
| 16 # Note: Should parse emails according to RFC2822 instead of performing a | 16 # Note: Should parse emails according to RFC2822 instead of performing a |
| 67 try: | 67 try: |
| 68 shutil.rmtree(self.dirname) | 68 shutil.rmtree(self.dirname) |
| 69 except OSError, error: | 69 except OSError, error: |
| 70 if error.errno not in (errno.ENOENT, errno.ESRCH): raise | 70 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
| 71 # create the instance | 71 # create the instance |
| 72 init.install(self.dirname, 'classic') | 72 init.install(self.dirname, 'templates/classic') |
| 73 init.write_select_db(self.dirname, 'anydbm') | 73 init.write_select_db(self.dirname, 'anydbm') |
| 74 init.initialise(self.dirname, 'sekrit') | 74 init.initialise(self.dirname, 'sekrit') |
| 75 # check we can load the package | 75 # check we can load the package |
| 76 self.instance = instance.open(self.dirname) | 76 self.instance = instance.open(self.dirname) |
| 77 # and open the database | 77 # and open the database |
| 213 | 213 |
| 214 New submission from Bork, Chef <chef@bork.bork.bork>: | 214 New submission from Bork, Chef <chef@bork.bork.bork>: |
| 215 | 215 |
| 216 This is a test submission of a new issue. | 216 This is a test submission of a new issue. |
| 217 | 217 |
| 218 | |
| 219 ---------- | 218 ---------- |
| 220 assignedto: richard | 219 assignedto: richard |
| 221 messages: 1 | 220 messages: 1 |
| 222 nosy: Chef, mary, richard | 221 nosy: Chef, mary, richard |
| 223 status: unread | 222 status: unread |
| 270 | 269 |
| 271 Contrary, Mary <mary@test> added the comment: | 270 Contrary, Mary <mary@test> added the comment: |
| 272 | 271 |
| 273 This is a second followup | 272 This is a second followup |
| 274 | 273 |
| 275 | |
| 276 ---------- | 274 ---------- |
| 277 status: unread -> chatting | 275 status: unread -> chatting |
| 278 _______________________________________________________________________ | 276 _______________________________________________________________________ |
| 279 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 277 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 280 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | 278 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> |
| 319 | 317 |
| 320 richard <richard@test> added the comment: | 318 richard <richard@test> added the comment: |
| 321 | 319 |
| 322 This is a followup | 320 This is a followup |
| 323 | 321 |
| 324 | |
| 325 ---------- | 322 ---------- |
| 326 assignedto: -> mary | 323 assignedto: -> mary |
| 327 nosy: +john, mary | 324 nosy: +john, mary |
| 328 status: unread -> chatting | 325 status: unread -> chatting |
| 329 _______________________________________________________________________ | 326 _______________________________________________________________________ |
| 366 | 363 |
| 367 richard <richard@test> added the comment: | 364 richard <richard@test> added the comment: |
| 368 | 365 |
| 369 This is a followup | 366 This is a followup |
| 370 | 367 |
| 371 | |
| 372 ---------- | 368 ---------- |
| 373 assignedto: -> mary | 369 assignedto: -> mary |
| 374 nosy: +john, mary | 370 nosy: +john, mary |
| 375 status: unread -> chatting | 371 status: unread -> chatting |
| 376 _______________________________________________________________________ | 372 _______________________________________________________________________ |
| 414 | 410 |
| 415 John Doe <john@test> added the comment: | 411 John Doe <john@test> added the comment: |
| 416 | 412 |
| 417 This is a followup | 413 This is a followup |
| 418 | 414 |
| 419 | |
| 420 ---------- | 415 ---------- |
| 421 nosy: +john | 416 nosy: +john |
| 422 status: unread -> chatting | 417 status: unread -> chatting |
| 423 _______________________________________________________________________ | 418 _______________________________________________________________________ |
| 424 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 419 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 463 | 458 |
| 464 richard <richard@test> added the comment: | 459 richard <richard@test> added the comment: |
| 465 | 460 |
| 466 This is a followup | 461 This is a followup |
| 467 | 462 |
| 468 | |
| 469 ---------- | 463 ---------- |
| 470 nosy: +john | 464 nosy: +john |
| 471 status: unread -> chatting | 465 status: unread -> chatting |
| 472 _______________________________________________________________________ | 466 _______________________________________________________________________ |
| 473 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 467 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 512 | 506 |
| 513 John Doe <john@test> added the comment: | 507 John Doe <john@test> added the comment: |
| 514 | 508 |
| 515 This is a followup | 509 This is a followup |
| 516 | 510 |
| 517 | |
| 518 ---------- | 511 ---------- |
| 519 nosy: +john | 512 nosy: +john |
| 520 status: unread -> chatting | 513 status: unread -> chatting |
| 521 _______________________________________________________________________ | 514 _______________________________________________________________________ |
| 522 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 515 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 560 | 553 |
| 561 John Doe <john@test> added the comment: | 554 John Doe <john@test> added the comment: |
| 562 | 555 |
| 563 This is a followup | 556 This is a followup |
| 564 | 557 |
| 565 | |
| 566 ---------- | 558 ---------- |
| 567 status: unread -> chatting | 559 status: unread -> chatting |
| 568 _______________________________________________________________________ | 560 _______________________________________________________________________ |
| 569 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 561 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 570 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | 562 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> |
| 608 | 600 |
| 609 richard <richard@test> added the comment: | 601 richard <richard@test> added the comment: |
| 610 | 602 |
| 611 This is a followup | 603 This is a followup |
| 612 | 604 |
| 613 | 605 ---------- |
| 614 ---------- | 606 status: unread -> chatting |
| 615 status: unread -> chatting | 607 _______________________________________________________________________ |
| 616 _______________________________________________________________________ | 608 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 617 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 609 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> |
| 618 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | 610 _______________________________________________________________________ |
| 619 _______________________________________________________________________ | 611 |
| 620 | 612 ''') |
| 621 ''') | 613 |
| 614 def testFollowupEmptyMessage(self): | |
| 615 self.doNewIssue() | |
| 616 | |
| 617 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 618 charset="iso-8859-1" | |
| 619 From: richard <richard@test> | |
| 620 To: issue_tracker@your.tracker.email.domain.example | |
| 621 Message-Id: <followup_dummy_id> | |
| 622 In-Reply-To: <dummy_test_message_id> | |
| 623 Subject: [issue1] Testing... [assignedto=mary; nosy=+john] | |
| 624 | |
| 625 ''') | |
| 626 handler = self.instance.MailGW(self.instance, self.db) | |
| 627 handler.trapExceptions = 0 | |
| 628 handler.main(message) | |
| 629 l = self.db.issue.get('1', 'nosy') | |
| 630 l.sort() | |
| 631 self.assertEqual(l, ['3', '4', '5', '6']) | |
| 632 | |
| 633 # should be no file created (ie. no message) | |
| 634 assert not os.path.exists(os.environ['SENDMAILDEBUG']) | |
| 622 | 635 |
| 623 def testNosyRemove(self): | 636 def testNosyRemove(self): |
| 624 self.doNewIssue() | 637 self.doNewIssue() |
| 625 | 638 |
| 626 message = cStringIO.StringIO('''Content-Type: text/plain; | 639 message = cStringIO.StringIO('''Content-Type: text/plain; |
| 852 | 865 |
| 853 richard <richard@test> added the comment: | 866 richard <richard@test> added the comment: |
| 854 | 867 |
| 855 This is a followup | 868 This is a followup |
| 856 | 869 |
| 857 | |
| 858 ---------- | 870 ---------- |
| 859 status: unread -> chatting | 871 status: unread -> chatting |
| 860 _______________________________________________________________________ | 872 _______________________________________________________________________ |
| 861 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 873 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 862 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | 874 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> |
| 916 self.assertEqual(uidFromAddress(self.db, ('', 'USER1@foo.com'), 0), i) | 928 self.assertEqual(uidFromAddress(self.db, ('', 'USER1@foo.com'), 0), i) |
| 917 i = self.db.user.create(username='user2', address='USER2@foo.com') | 929 i = self.db.user.create(username='user2', address='USER2@foo.com') |
| 918 self.assertEqual(uidFromAddress(self.db, ('', 'USER2@foo.com'), 0), i) | 930 self.assertEqual(uidFromAddress(self.db, ('', 'USER2@foo.com'), 0), i) |
| 919 self.assertEqual(uidFromAddress(self.db, ('', 'user2@foo.com'), 0), i) | 931 self.assertEqual(uidFromAddress(self.db, ('', 'user2@foo.com'), 0), i) |
| 920 | 932 |
| 933 def testUserCreate(self): | |
| 934 i = uidFromAddress(self.db, ('', 'user@foo.com'), 1) | |
| 935 self.assertNotEqual(uidFromAddress(self.db, ('', 'user@bar.com'), 1), i) | |
| 936 | |
| 921 def suite(): | 937 def suite(): |
| 922 l = [unittest.makeSuite(MailgwTestCase), | 938 l = [unittest.makeSuite(MailgwTestCase), |
| 923 ] | 939 ] |
| 924 return unittest.TestSuite(l) | 940 return unittest.TestSuite(l) |
| 925 | 941 |
