forked from buildbot/buildbot
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_status_mail_MailNotifier.py
51 lines (43 loc) · 1.79 KB
/
test_status_mail_MailNotifier.py
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
import mock
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(object):
def getName(self):
return 'step-name'
return FakeStep()
def getText(self):
return self.text
class TestMailNotifier(unittest.TestCase):
def make_build(self):
# we may eventually need to add some attributes here
b = mock.Mock()
def test_createEmail_message_without_patch_and_log_contains_unicode(self):
build = self.make_build()
msgdict = dict(body=u'Unicode body with non-ascii (\u00E5\u00E4\u00F6).',
type='plain')
mn = MailNotifier('from@example.org')
m = mn.createEmail(msgdict, u'builder-n\u00E5me', u'project-n\u00E5me', SUCCESS, build)
try:
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):
build = self.make_build()
msgdict = dict(body=u'Unicode body with non-ascii (\u00E5\u00E4\u00F6).',
type='plain')
patch = ['', u'\u00E5\u00E4\u00F6', '']
logs = [FakeLog(u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).')]
mn = MailNotifier('from@example.org', addLogs=True)
m = mn.createEmail(msgdict, u'builder-n\u00E5me', u'project-n\u00E5me', SUCCESS,
build, patch, logs)
try:
m.as_string()
except UnicodeEncodeError:
self.fail('Failed to call as_string() on email message.')