1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
from unittest import makeSuite
from base import SquishdotBase
import re
class MailTests(SquishdotBase):
def _mail(self,Posting):
Site = self.Site
mail =Site.mail_html(Site,
Site.REQUEST,
newItem=Posting,
email='test@address.com')
f = open('%s.mailre' % Posting.title,'r')
mailre = re.compile('^%s$' % f.read())
f.close()
assert mailre.match(mail)
def testMailHTMLArticle(self):
"Check HTML Article Mailing"
id = self._addPosting(title = 'testMailHTMLArticle',
author = 'tester',
body = '<b>body</b><br><i>italic</i>',
email = 'email',
notify = 1,
encoding = 'HTML',
subject = 'test subject',
summary = '<hr>summary<p>no way</p>',
dept = 'dept')
self._mail(self.Site[id])
def testMailPlainArticle(self):
"Check Plain Article Mailing"
id = self._addPosting(title = 'testMailPlainArticle',
author = 'tester',
body = '<b>body</b><br><i>italic</i>',
email = 'email',
notify = 1,
encoding = 'Plain',
subject = 'test subject',
summary = '<hr>summary<p>no way</p>',
dept = 'dept')
self._mail(self.Site[id])
def testMailHTMLComment(self):
"Check HTML Comment Mailing"
parent = self._getPosting()
id = self._addPosting(object = parent,
title = 'testMailHTMLComment',
author = 'tester',
body = '<b>body</b><br><i>italic</i>',
email = 'email',
notify = 1,
encoding = 'HTML')
self._mail(self.Site[parent.getId()][id])
def testMailPlainComment(self):
"Check Plain Comment Mailing"
parent = self._getPosting()
id = self._addPosting(object = parent,
title = 'testMailPlainComment',
author = 'tester',
body = '<b>body</b><br><i>italic</i>',
email = 'email',
notify = 1,
encoding = 'Plain')
self._mail(self.Site[parent.getId()][id])
def test_suite():
return makeSuite(MailTests)
def debug():
test_suite().debug()
|