PageRenderTime 66ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/Squishdot/tags/1.3.0/tests/testMail.py

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