Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 2822:f0b887a5e47b
use tracker setup function from db_test_base
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sun, 24 Oct 2004 10:01:58 +0000 |
| parents | d694b408a8bc |
| children | cfe7d8cb9794 f412ae175b4d |
comparison
equal
deleted
inserted
replaced
| 2821:0f0299b2a5e8 | 2822:f0b887a5e47b |
|---|---|
| 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.72 2004-09-29 09:34:26 a1s Exp $ | 11 # $Id: test_mailgw.py,v 1.73 2004-10-24 10:01:58 a1s Exp $ |
| 12 | 12 |
| 13 # TODO: test bcc | 13 # TODO: test bcc |
| 14 | 14 |
| 15 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 | 15 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 |
| 16 | 16 |
| 22 | 22 |
| 23 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \ | 23 from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, \ |
| 24 parseContent, IgnoreLoop, IgnoreBulk | 24 parseContent, IgnoreLoop, IgnoreBulk |
| 25 from roundup import init, instance, password, rfc2822, __version__ | 25 from roundup import init, instance, password, rfc2822, __version__ |
| 26 | 26 |
| 27 import db_test_base | |
| 27 | 28 |
| 28 class Message(rfc822.Message): | 29 class Message(rfc822.Message): |
| 29 """String-based Message class with equivalence test.""" | 30 """String-based Message class with equivalence test.""" |
| 30 def __init__(self, s): | 31 def __init__(self, s): |
| 31 rfc822.Message.__init__(self, StringIO(s.strip())) | 32 rfc822.Message.__init__(self, StringIO(s.strip())) |
| 93 count = 0 | 94 count = 0 |
| 94 schema = 'classic' | 95 schema = 'classic' |
| 95 def setUp(self): | 96 def setUp(self): |
| 96 MailgwTestCase.count = MailgwTestCase.count + 1 | 97 MailgwTestCase.count = MailgwTestCase.count + 1 |
| 97 self.dirname = '_test_mailgw_%s'%self.count | 98 self.dirname = '_test_mailgw_%s'%self.count |
| 98 try: | 99 # set up and open a tracker |
| 99 shutil.rmtree(self.dirname) | 100 self.instance = db_test_base.setupTracker(self.dirname) |
| 100 except OSError, error: | |
| 101 if error.errno not in (errno.ENOENT, errno.ESRCH): raise | |
| 102 # create the instance | |
| 103 init.install(self.dirname, 'templates/classic') | |
| 104 init.write_select_db(self.dirname, 'anydbm') | |
| 105 self.instance = tracker = instance.open(self.dirname) | |
| 106 if tracker.exists(): | |
| 107 tracker.nuke() | |
| 108 tracker.init(password.Password('sekrit')) | |
| 109 | 101 |
| 110 # and open the database | 102 # and open the database |
| 111 self.db = self.instance.open('admin') | 103 self.db = self.instance.open('admin') |
| 112 self.chef_id = self.db.user.create(username='Chef', | 104 self.chef_id = self.db.user.create(username='Chef', |
| 113 address='chef@bork.bork.bork', realname='Bork, Chef', roles='User') | 105 address='chef@bork.bork.bork', realname='Bork, Chef', roles='User') |
