~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-23 13:35:31 UTC
  • mfrom: (12906.2.8 question-emails-0)
  • Revision ID: launchpad@pqm.canonical.com-20110423133531-z4r70fh65369ulhy
[rs=sinzui][bug=351136][bug=239158][bug=597982] Fix 'requested more
 information', detect the signature separator properly,
 simplify email subject lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        self.notification = TestQuestionModifiedNotification(
67
67
            StubQuestion(), FakeEvent())
68
68
 
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")
 
73
        self.assertEqual(
 
74
            "body\n-- \nrationale", formatted_body)
 
75
 
 
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")
 
80
        self.assertEqual(
 
81
            "body -- mdash\n-- \nrationale", formatted_body)
 
82
 
 
83
    def test_getSubject(self):
70
84
        """getSubject() when there is no message added to the question."""
71
85
        self.assertEquals(
72
 
            '[Question #1]: Question title', self.notification.getSubject())
73
 
 
74
 
    def test_getSubject_new_message(self):
75
 
        """Test getSubject() when there is a new message."""
76
 
        self.notification.new_message = StubQuestionMessage()
77
 
        self.assertEquals(
78
 
            '[Question #1]: Message subject',
79
 
            self.notification.getSubject())
80
 
 
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())
87
 
 
88
 
        self.notification.new_message.subject = 'Re: Message subject'
89
 
        self.assertEquals('Re: [Question #1]: Message subject',
90
 
            self.notification.getSubject())
91
 
 
92
 
        self.notification.new_message.subject = 're: Message subject'
93
 
        self.assertEquals('re: [Question #1]: Message subject',
94
 
            self.notification.getSubject())
95
 
 
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())
102
 
 
103
 
        self.notification.new_message.subject = (
104
 
            'Re: [Question #1]: Message subject')
105
 
        self.assertEquals(
106
 
            'Re: [Question #1]: Message subject',
107
 
            self.notification.getSubject())
108
 
 
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')
113
 
        self.assertEquals(
114
 
            'Re: [Question #1]: Message subject',
 
86
            'Re: [Question #1]: Question title',
115
87
            self.notification.getSubject())
116
88
 
117
89
    def test_user_is_event_user(self):