forked from buildbot/buildbot
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/brasse/buildbot
* 'master' of git://github.com/brasse/buildbot: Fixed email creation bug in MailNotifier. Refactored to be able to test email creation.
- Loading branch information
Dustin J. Mitchell
committed
Mar 13, 2010
1 parent
1400c91
commit 0970781
Showing
2 changed files
with
85 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from twisted.trial import unittest | ||
|
||
from buildbot.status.builder import SUCCESS | ||
from buildbot.status.mail import MailNotifier | ||
|
||
class FakeLog(object): | ||
def __init__(self, text): | ||
self.text = text | ||
|
||
def getName(self): | ||
return 'log-name' | ||
|
||
def getStep(self): | ||
class FakeStep(): | ||
def getName(self): | ||
return 'step-name' | ||
return FakeStep() | ||
|
||
def getText(self): | ||
return self.text | ||
|
||
class TestMailNotifier(unittest.TestCase): | ||
def test_createEmail_message_without_patch_and_log_contains_unicode(self): | ||
msgdict = dict(body=u'Unicode body with non-ascii (åäö).', | ||
type='plain') | ||
mn = MailNotifier('from@example.org') | ||
m = mn.createEmail(msgdict, u'builder-näme', u'project-näme', SUCCESS) | ||
try: | ||
print m.as_string() | ||
except UnicodeEncodeError: | ||
self.fail('Failed to call as_string() on email message.') | ||
|
||
def test_createEmail_message_with_patch_and_log_contains_unicode(self): | ||
msgdict = dict(body=u'Unicode body with non-ascii (åäö).', | ||
type='plain') | ||
patch = ['', u'åäö', ''] | ||
logs = [FakeLog(u'Unicode log with non-ascii (åäö).')] | ||
mn = MailNotifier('from@example.org', addLogs=True) | ||
m = mn.createEmail(msgdict, u'builder-näme', u'project-näme', SUCCESS, | ||
patch, logs) | ||
try: | ||
m.as_string() | ||
except UnicodeEncodeError: | ||
self.fail('Failed to call as_string() on email message.') |