~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/answers/tests/test_question_notifications.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-04-22 23:49:30 UTC
  • mfrom: (12906.1.11 bugtask-create-question-1)
  • Revision ID: launchpad@pqm.canonical.com-20110422234930-291lizhngx17pqiq
[r=bac][bug=438116] Send the first and last messages only when
 converting a bug to a question.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
from zope.interface import implements
11
11
 
12
 
from lp.answers.notification import QuestionModifiedDefaultNotification
 
12
from lp.answers.notification import (
 
13
    QuestionAddedNotification,
 
14
    QuestionModifiedDefaultNotification,
 
15
    )
13
16
from lp.registry.interfaces.person import IPerson
14
17
 
15
18
 
35
38
    def __init__(self, id=1, title="Question title"):
36
39
        self.id = id
37
40
        self.title = title
 
41
        self.owner = FakeUser()
38
42
 
39
43
 
40
44
class StubQuestionMessage:
109
113
        self.assertEquals(
110
114
            'Re: [Question #1]: Message subject',
111
115
            self.notification.getSubject())
 
116
 
 
117
    def test_user_is_event_user(self):
 
118
        """The notification user is always the event user."""
 
119
        question = StubQuestion()
 
120
        event = FakeEvent()
 
121
        notification = TestQuestionModifiedNotification(question, event)
 
122
        self.assertEqual(event.user, notification.user)
 
123
        self.assertNotEqual(question.owner, notification.user)
 
124
 
 
125
 
 
126
class TestQuestionAddedNotification(QuestionAddedNotification):
 
127
    """A subclass that does not send emails."""
 
128
 
 
129
    def shouldNotify(self):
 
130
        return False
 
131
 
 
132
 
 
133
class QuestionCreatedTestCase(TestCase):
 
134
    """Test cases for mail notifications about created questions."""
 
135
 
 
136
    def test_user_is_question_owner(self):
 
137
        """The notification user is always the question owner."""
 
138
        question = StubQuestion()
 
139
        event = FakeEvent()
 
140
        notification = TestQuestionAddedNotification(question, event)
 
141
        self.assertEqual(question.owner, notification.user)
 
142
        self.assertNotEqual(event.user, notification.user)