Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 5033:63c79c0992ae
Update tests to work with py.test
py.test searches for any class that looks like a TestCase in the test
directory and tries to run them as tests. Some of the classes that
inherit TestCase are not meant to be run and are only intended to be
"helper classes". Only the tests of the classes that inherit the "helper
classes" should be run. If we convert these "helper classes" to be
"mixins" py.test should not pick them up.
| author | John Kristensen <john@jerrykan.com> |
|---|---|
| date | Thu, 20 Aug 2015 14:44:49 +1000 |
| parents | 868db43b302a |
| children | 380d8d8b30a3 |
comparison
equal
deleted
inserted
replaced
| 5032:fc0f7655411b | 5033:63c79c0992ae |
|---|---|
| 139 | 139 |
| 140 return res | 140 return res |
| 141 | 141 |
| 142 from roundup.hyperdb import String | 142 from roundup.hyperdb import String |
| 143 | 143 |
| 144 class MailgwTestAbstractBase(unittest.TestCase, DiffHelper): | 144 |
| 145 class MailgwTestAbstractBase(DiffHelper): | |
| 145 count = 0 | 146 count = 0 |
| 146 schema = 'classic' | 147 schema = 'classic' |
| 147 def setUp(self): | 148 def setUp(self): |
| 148 self.old_translate_ = mailgw._ | 149 self.old_translate_ = mailgw._ |
| 149 roundupdb._ = mailgw._ = i18n.get_translation(language='C').gettext | 150 roundupdb._ = mailgw._ = i18n.get_translation(language='C').gettext |
| 231 assert not os.path.exists(SENDMAILDEBUG) | 232 assert not os.path.exists(SENDMAILDEBUG) |
| 232 self.assertEqual(self.db.issue.get(nodeid, 'title'), 'Testing...') | 233 self.assertEqual(self.db.issue.get(nodeid, 'title'), 'Testing...') |
| 233 self.assertEqual(self.db.issue.get(nodeid, 'tx_Source'), 'email') | 234 self.assertEqual(self.db.issue.get(nodeid, 'tx_Source'), 'email') |
| 234 | 235 |
| 235 | 236 |
| 236 class MailgwTestCase(MailgwTestAbstractBase): | 237 class MailgwTestCase(MailgwTestAbstractBase, unittest.TestCase): |
| 237 | 238 |
| 238 def testMessageWithFromInIt(self): | 239 def testMessageWithFromInIt(self): |
| 239 nodeid = self._handle_mail('''Content-Type: text/plain; | 240 nodeid = self._handle_mail('''Content-Type: text/plain; |
| 240 charset="iso-8859-1" | 241 charset="iso-8859-1" |
| 241 From: Chef <chef@bork.bork.bork> | 242 From: Chef <chef@bork.bork.bork> |
| 3259 'Catch this exception and log it without emailing.') | 3260 'Catch this exception and log it without emailing.') |
| 3260 self.assertEqual(self.db.msg.get(msgid, 'files'), ['1']) | 3261 self.assertEqual(self.db.msg.get(msgid, 'files'), ['1']) |
| 3261 fileid = self.db.msg.get(msgid, 'files')[0] | 3262 fileid = self.db.msg.get(msgid, 'files')[0] |
| 3262 self.assertEqual(self.db.file.get(fileid, 'type'), 'message/rfc822') | 3263 self.assertEqual(self.db.file.get(fileid, 'type'), 'message/rfc822') |
| 3263 | 3264 |
| 3264 class MailgwPGPTestCase(MailgwTestAbstractBase): | 3265 |
| 3266 class MailgwPGPTestCase(MailgwTestAbstractBase, unittest.TestCase): | |
| 3265 pgphome = gpgmelib.pgphome | 3267 pgphome = gpgmelib.pgphome |
| 3266 def setUp(self): | 3268 def setUp(self): |
| 3267 MailgwTestAbstractBase.setUp(self) | 3269 MailgwTestAbstractBase.setUp(self) |
| 3268 self.db.security.addRole(name = 'pgp', description = 'PGP Role') | 3270 self.db.security.addRole(name = 'pgp', description = 'PGP Role') |
| 3269 self.instance.config['PGP_HOMEDIR'] = self.pgphome | 3271 self.instance.config['PGP_HOMEDIR'] = self.pgphome |
