def testMessageObjectToKind(self): statusCode, mailKind = message.messageObjectToKind(self.view, self.__getMessageObject(), self.__mail) self.assertNotEqual(mailKind, None) self.__compareMailMessages(mailKind, self.__getMailMessage())
def testI18nMessage(self): """ Basic unit test which loads a mail message in the utf-8 charset encoding off the filesystem and converts the bytes to a Chandler C{Mail.MailMessage}. This Chandler c{Mail.MailMessage} is then converted back to bytes for sending. The bytes contained in the To, From, Subject, and Body payload are compared with the original. This test confirms that encoded headers are decoded to Unicode, The Body is converted from bytes to Unicode, and that the headers and Body are properly encoded back to bytes. A header in a non-ascii charset should be encoded for sending. For example: To: =?utf-8?b?IsSFxI3EmcSXxK/FocWzxavFviDEhMSMxJjElsSuxaDFssWqxb0i?= <*****@*****.**> """ msgText = self.__loadTestMessage() mOne = email.message_from_string(msgText) messageKind = message.messageObjectToKind(self.view, mOne, msgText)[1] mTwo = message.kindToMessageObject(messageKind) self.assertEquals(mOne['To'], mTwo['To']) self.assertEquals(mOne['From'], mTwo['From']) self.assertEquals(mOne['Subject'], mTwo['Subject']) o = mOne.get_payload(decode=True) self.assertEquals(o, mTwo.get_payload()[0].get_payload()[1].get_payload(decode=True))