~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/messages/tests/test_message.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-01 15:40:36 UTC
  • mfrom: (13142.1.2 no-dedup)
  • Revision ID: launchpad@pqm.canonical.com-20110601154036-l1bzevb2ix1yhuoh
[r=lifeless][bug=595166] Stop corner-case combining emails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
__metaclass__ = type
5
5
 
6
6
from cStringIO import StringIO
7
 
from doctest import DocTestSuite
8
7
from email.Message import Message
9
8
from email.MIMEMultipart import MIMEMultipart
10
9
from email.MIMEText import MIMEText
60
59
        expected = {
61
60
            message1: [message2, message3],
62
61
            message2: [message4],
63
 
            message3: [], message4:[]}
 
62
            message3: [], message4: []}
64
63
        result, roots = MessageSet._parentToChild(messages)
65
64
        self.assertEqual(expected, result)
66
65
        self.assertEqual([message1], roots)
141
140
        transaction.commit()
142
141
        self.assertEqual('This is the diff, honest.', diff.blob.read())
143
142
 
 
143
    def test_fromEmail_always_creates(self):
 
144
        """Even when messages are identical, fromEmail creates a new one."""
 
145
        email = self.factory.makeEmailMessage()
 
146
        orig_message = MessageSet().fromEmail(email.as_string())
 
147
        # update librarian
 
148
        transaction.commit()
 
149
        dupe_message = MessageSet().fromEmail(email.as_string())
 
150
        self.assertNotEqual(orig_message.id, dupe_message.id)
 
151
 
144
152
 
145
153
class TestMessageJob(TestCaseWithFactory):
146
154
    """Tests for MessageJob."""