66
66
self.notification = TestQuestionModifiedNotification(
67
67
StubQuestion(), FakeEvent())
69
def test_getSubject_no_new_message(self):
69
def test_buildBody_with_separator(self):
70
# A body with a separator is preserved.
71
formatted_body = self.notification.buildBody(
72
"body\n-- ", "rationale")
74
"body\n-- \nrationale", formatted_body)
76
def test_buildBody_without_separator(self):
77
# A separator will added to body if one is not present.
78
formatted_body = self.notification.buildBody(
79
"body -- mdash", "rationale")
81
"body -- mdash\n-- \nrationale", formatted_body)
83
def test_getSubject(self):
70
84
"""getSubject() when there is no message added to the question."""
72
'[Question #1]: Question title', self.notification.getSubject())
74
def test_getSubject_new_message(self):
75
"""Test getSubject() when there is a new message."""
76
self.notification.new_message = StubQuestionMessage()
78
'[Question #1]: Message subject',
79
self.notification.getSubject())
81
def test_getSubject_new_message_with_reply_prefix(self):
82
"""getSubject() when there is a new message with a reply prefix."""
83
self.notification.new_message = StubQuestionMessage(
84
'RE: Message subject')
85
self.assertEquals('RE: [Question #1]: Message subject',
86
self.notification.getSubject())
88
self.notification.new_message.subject = 'Re: Message subject'
89
self.assertEquals('Re: [Question #1]: Message subject',
90
self.notification.getSubject())
92
self.notification.new_message.subject = 're: Message subject'
93
self.assertEquals('re: [Question #1]: Message subject',
94
self.notification.getSubject())
96
def test_getSubject_with_existing_prefix(self):
97
"""Test getSubject() when there is already a [Question #xx] prefix."""
98
self.notification.new_message = StubQuestionMessage(
99
'[Question #1]: Question title')
100
self.assertEquals('[Question #1]: Question title',
101
self.notification.getSubject())
103
self.notification.new_message.subject = (
104
'Re: [Question #1]: Message subject')
106
'Re: [Question #1]: Message subject',
107
self.notification.getSubject())
109
def test_getSubject_old_prefix(self):
110
"""Test that getSubject() with an old [Support #dd] prefix."""
111
self.notification.new_message = StubQuestionMessage(
112
'Re: [Support #1]: Message subject')
114
'Re: [Question #1]: Message subject',
86
'Re: [Question #1]: Question title',
115
87
self.notification.getSubject())
117
89
def test_user_is_event_user(self):