def setUp(self, key):
     # is there a better way?  TestCase.mktemp() doesn't work otherwise
     self._testMethodName = key
     self.setUpMailStuff()
     p = self.createMIMEReceiver().feedStringNow(
         PartMaker('multipart/alternative', 'alt',
             PartMaker('text/plain', 'this is the text/plain'),
             PartMaker('text/html', 'this is the text/html')).make())
     f = MessageBodyFragment(p.message, 'text/plain')
     f.setFragmentParent(self)
     return f
示例#2
0
    def test_getAlternateMIMETypesMixed(self):
        """
        Test that there are no alternate MIME types returned by
        L{xquotient.exmess.MessageBodyFragment.getAlternateMIMETypes} for
        L{mixed}
        """
        self.setUpMailStuff()
        m = self.createMIMEReceiver().feedStringNow(self.mixed).message
        messageBody = MessageBodyFragment(m, 'text/plain')

        self.assertEqual(list(messageBody.getAlternateMIMETypes()), [])
示例#3
0
    def test_alternateMIMETypesAltMixed(self):
        """
        Test that C{text/html} is the only alternate MIME type returned by
        L{xquotient.exmess.MessageBodyFragment.getAlternateMIMETypes} for
        L{altInsideMixed}
        """
        self.setUpMailStuff()
        m = self.createMIMEReceiver().feedStringNow(
            self.altInsideMixed).message
        messageBody = MessageBodyFragment(m, 'text/plain')

        self.assertEqual(list(messageBody.getAlternateMIMETypes()),
                         ['text/html'])
示例#4
0
    def test_getAlternateMIMETypesMixed(self):
        """
        Test that there are no alternate MIME types returned by
        L{xquotient.exmess.MessageBodyFragment.getAlternateMIMETypes} for
        L{mixed}
        """
        self.setUpMailStuff()
        m = self.createMIMEReceiver().feedStringNow(
            self.mixed).message
        messageBody = MessageBodyFragment(m, 'text/plain')

        self.assertEqual(
            list(messageBody.getAlternateMIMETypes()), [])
示例#5
0
    def test_alternateMIMETypesAltMixed(self):
        """
        Test that C{text/html} is the only alternate MIME type returned by
        L{xquotient.exmess.MessageBodyFragment.getAlternateMIMETypes} for
        L{altInsideMixed}
        """
        self.setUpMailStuff()
        m = self.createMIMEReceiver().feedStringNow(
            self.altInsideMixed).message
        messageBody = MessageBodyFragment(m, 'text/plain')

        self.assertEqual(
            list(messageBody.getAlternateMIMETypes()), ['text/html'])
示例#6
0
    def test_getAlternatePartBodyAltMixed(self):
        """
        Test that the parts returned from
        L{xquotient.exmess.MessageBodyFragment.getAlternatePartBody} are of
        the type C{text/html} and C{text/plain}, in that order, when asked for
        C{text/html} part bodies from L{altInsideMixed}
        """
        self.setUpMailStuff()
        m = self.createMIMEReceiver().feedStringNow(
            self.altInsideMixed).message
        messageBody = MessageBodyFragment(m, 'text/plain')
        messageBody = messageBody.getAlternatePartBody('text/html')

        self.assertEqual(list(p.type for p in messageBody.parts),
                         ['text/html', 'text/plain'])
示例#7
0
    def test_getAlternatePartBodyAltMixed(self):
        """
        Test that the parts returned from
        L{xquotient.exmess.MessageBodyFragment.getAlternatePartBody} are of
        the type C{text/html} and C{text/plain}, in that order, when asked for
        C{text/html} part bodies from L{altInsideMixed}
        """
        self.setUpMailStuff()
        m = self.createMIMEReceiver().feedStringNow(
            self.altInsideMixed).message
        messageBody = MessageBodyFragment(m, 'text/plain')
        messageBody = messageBody.getAlternatePartBody('text/html')

        self.assertEqual(
            list(p.type for p in messageBody.parts),
            ['text/html', 'text/plain'])