Example #1
0
 def test_slotData(self):
     """
     Verify that L{DraftComposeFragment.slotData} returns a dictionary
     which reflects the message which was used as the draft.
     """
     subject = u'subject text'
     body = u'hello, world?\n'
     to = u'*****@*****.**'
     cc = u'*****@*****.**'
     bcc = u'*****@*****.**'
     message = createMessage(
         self.composer,
         None,
         None,
         self.defaultFromAddress,
         [mimeutil.EmailAddress(to, mimeEncoded=False)],
         subject,
         body,
         [mimeutil.EmailAddress(cc, mimeEncoded=False)],
         [mimeutil.EmailAddress(bcc, mimeEncoded=False)],
         [],
         )
     fragment = self.messageDetail._composeSomething(draft=message)
     slotData = fragment.slotData()
     self.assertEqual(slotData['to'], to)
     self.assertEqual(slotData['from'][0], self.defaultFromAddress)
     self.assertEqual(slotData['subject'], subject)
     self.assertEqual(slotData['message-body'], body)
     self.assertEqual(slotData['cc'], cc)
Example #2
0
 def test_slotData(self):
     """
     Verify that L{DraftComposeFragment.slotData} returns a dictionary
     which reflects the message which was used as the draft.
     """
     subject = u'subject text'
     body = u'hello, world?\n'
     to = u'*****@*****.**'
     cc = u'*****@*****.**'
     bcc = u'*****@*****.**'
     message = createMessage(
         self.composer,
         None,
         None,
         self.defaultFromAddress,
         [mimeutil.EmailAddress(to, mimeEncoded=False)],
         subject,
         body,
         [mimeutil.EmailAddress(cc, mimeEncoded=False)],
         [mimeutil.EmailAddress(bcc, mimeEncoded=False)],
         [],
     )
     fragment = self.messageDetail._composeSomething(draft=message)
     slotData = fragment.slotData()
     self.assertEqual(slotData['to'], to)
     self.assertEqual(slotData['from'][0], self.defaultFromAddress)
     self.assertEqual(slotData['subject'], subject)
     self.assertEqual(slotData['message-body'], body)
     self.assertEqual(slotData['cc'], cc)
    def test_createsPlaintextMessage(self):
        """
        Test that L{mimebakery.createMessage} produces a message of
        type text/plain.
        """

        msg = createMessage(
            self.composer, None, None, self.defaultFromAddr,
            [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)],
            u'Sup dood', u'A body', u'', u'', u'')

        self.assertEqual(msg.impl.getContentType(), 'text/plain')
 def test_createReplyNoMessageID(self):
     """
     Test replying to messages with no message ID.
     """
     parent = MsgStub()
     parent.impl.headers = []
     msg = createMessage(
         self.composer, self.cabinet, parent, self.defaultFromAddr,
         [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)],
         u'Sup dood', u'A body', (), (), u'')
     self.assertEqual([h.value for h in msg.impl.getHeaders('References')],
                      [])
 def test_createMessageHonorsSmarthostFromAddress(self):
     """
     Sending a message through the Compose UI should honor the from
     address we give to it
     """
     self.defaultFromAddr.address = u'*****@*****.**'
     msg = createMessage(
         self.composer, self.cabinet, None, self.defaultFromAddr,
         [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)],
         u'Sup dood', u'A body', (), (), u'')
     file = msg.impl.source.open()
     msg = Parser.Parser().parse(file)
     self.assertEquals(msg["from"], '*****@*****.**')
 def _createMessageWithFiles(self, files):
     """
     Create a message with attachments corresponding to the
     L{xquotient.compose.File} items C{files}
     """
     return createMessage(
         self.composer,
         self.cabinet,
         None,
         self.defaultFromAddr,
         [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)],
         u'subject',
         u'body', (), (),
         files=list(f.storeID for f in files))
Example #7
0
 def _createMessageWithFiles(self, files):
     """
     Create a message with attachments corresponding to the
     L{xquotient.compose.File} items C{files}
     """
     return createMessage(self.composer,
                          self.cabinet,
                          None,
                          self.defaultFromAddr,
                             [mimeutil.EmailAddress(
                                 '*****@*****.**',
                                 mimeEncoded=False)],
                             u'subject', u'body', (), (),
                             files=list(f.storeID for f in files))
 def test_createMessageNotIncoming(self):
     """
     Verify that a message composed via the compose form does not deposit
     anything into the 'incoming' state, so the spam filter will not be
     triggered.
     """
     sq = exmess.MailboxSelector(self.userStore)
     msg = createMessage(
         self.composer, self.cabinet, None, self.defaultFromAddr,
         [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)],
         u'Sup dood', u'A body', u'', u'', u'')
     sq.refineByStatus(exmess.INCOMING_STATUS)
     self.assertEquals(list(sq), [])
     self.assertEquals(msg.hasStatus(exmess.CLEAN_STATUS), False)
     self.failIf(msg.shouldBeClassified)
    def _createMessage(self, cc=(), bcc=()):
        """
        Use L{xquotient.mimebakery.createMessage} to make a
        simple message, optionally with CC/BCC headers set

        @param cc: addresses to CC the message to.  defaults to no addresses
        @type cc: sequence of L{xquotient.mimeutils.EmailAddress}
        @param bcc: addresses to BCC the message to.  defaults to no addresses
        @type bcc: sequence of L{xquotient.mimeutils.EmailAddress}

        @return: L{xquotient.exmess.Message}
        """
        return createMessage(
            self.composer, self.cabinet, None, self.defaultFromAddr,
            [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)], u'',
            u'', cc, bcc, u'')
Example #10
0
    def test_createsPlaintextMessage(self):
        """
        Test that L{mimebakery.createMessage} produces a message of
        type text/plain.
        """

        msg = createMessage(
            self.composer,
            None, None,
            self.defaultFromAddr,
            [mimeutil.EmailAddress(
              '*****@*****.**',
               mimeEncoded=False)],
            u'Sup dood', u'A body', u'', u'', u'')

        self.assertEqual(msg.impl.getContentType(), 'text/plain')
Example #11
0
 def test_createReplyNoMessageID(self):
     """
     Test replying to messages with no message ID.
     """
     parent = MsgStub()
     parent.impl.headers = []
     msg = createMessage(self.composer,
                         self.cabinet,
                         parent,
                         self.defaultFromAddr,
         [mimeutil.EmailAddress(
                 '*****@*****.**',
                 mimeEncoded=False)],
         u'Sup dood', u'A body', (), (), u'')
     self.assertEqual([h.value for h in msg.impl.getHeaders('References')],
                      [])
Example #12
0
 def test_createMessageHonorsSmarthostFromAddress(self):
     """
     Sending a message through the Compose UI should honor the from
     address we give to it
     """
     self.defaultFromAddr.address = u'*****@*****.**'
     msg = createMessage(self.composer,
                         self.cabinet,
                         None,
                         self.defaultFromAddr,
         [mimeutil.EmailAddress(
                 '*****@*****.**',
                 mimeEncoded=False)],
         u'Sup dood', u'A body', (), (), u'')
     file = msg.impl.source.open()
     msg = Parser.Parser().parse(file)
     self.assertEquals(msg["from"], '*****@*****.**')
Example #13
0
 def test_createMessageNotIncoming(self):
     """
     Verify that a message composed via the compose form does not deposit
     anything into the 'incoming' state, so the spam filter will not be
     triggered.
     """
     sq = exmess.MailboxSelector(self.userStore)
     msg = createMessage(
         self.composer,
         self.cabinet,
         None,
         self.defaultFromAddr,
         [mimeutil.EmailAddress(
                 '*****@*****.**',
                 mimeEncoded=False)],
         u'Sup dood', u'A body', u'', u'', u'')
     sq.refineByStatus(exmess.INCOMING_STATUS)
     self.assertEquals(list(sq), [])
     self.assertEquals(msg.hasStatus(exmess.CLEAN_STATUS), False)
     self.failIf(msg.shouldBeClassified)
Example #14
0
    def _createMessage(self, cc=(), bcc=()):
        """
        Use L{xquotient.mimebakery.createMessage} to make a
        simple message, optionally with CC/BCC headers set

        @param cc: addresses to CC the message to.  defaults to no addresses
        @type cc: sequence of L{xquotient.mimeutils.EmailAddress}
        @param bcc: addresses to BCC the message to.  defaults to no addresses
        @type bcc: sequence of L{xquotient.mimeutils.EmailAddress}

        @return: L{xquotient.exmess.Message}
        """
        return createMessage(
            self.composer,
            self.cabinet,
            None,
            self.defaultFromAddr,
            [mimeutil.EmailAddress(
                '*****@*****.**',
                mimeEncoded=False)],
            u'', u'', cc, bcc, u'')
 def test_createReply(self):
     """
     Ensure that References and In-Reply-To headers are added to
     outgoing messages.
     """
     parent = MsgStub()
     parent.impl.headers = [
         Header("message-id", "<*****@*****.**>"),
         Header("references", "<*****@*****.**>"),
         Header("references", "<*****@*****.**>")
     ]
     msg = createMessage(
         self.composer, self.cabinet, parent, self.defaultFromAddr,
         [mimeutil.EmailAddress('*****@*****.**', mimeEncoded=False)],
         u'Sup dood', u'A body', (), (), u'')
     self.assertEqual([h.value for h in msg.impl.getHeaders('References')],
                      [
                          "<*****@*****.**>", "<*****@*****.**>",
                          "<*****@*****.**>"
                      ])
     self.assertEqual(msg.impl.getHeader("In-Reply-To"),
                      "<*****@*****.**>")
Example #16
0
 def test_createReply(self):
     """
     Ensure that References and In-Reply-To headers are added to
     outgoing messages.
     """
     parent = MsgStub()
     parent.impl.headers = [Header("message-id", "<*****@*****.**>"),
                            Header("references", "<*****@*****.**>"),
                            Header("references", "<*****@*****.**>")]
     msg = createMessage(self.composer,
                         self.cabinet,
                         parent,
                         self.defaultFromAddr,
         [mimeutil.EmailAddress(
                 '*****@*****.**',
                 mimeEncoded=False)],
         u'Sup dood', u'A body', (), (), u'')
     self.assertEqual([h.value for h in msg.impl.getHeaders('References')],
                      ["<*****@*****.**>",
                       "<*****@*****.**>",
                      "<*****@*****.**>"])
     self.assertEqual(msg.impl.getHeader("In-Reply-To"),
                      "<*****@*****.**>")