Ticket #1978: ticket1978_unittest.diff

File ticket1978_unittest.diff, 1.4 KB (added by tvachon, 16 years ago)

Unittest for this defect

  • .py

    old new  
    21462146        d = loopback.loopbackTCP(self.server, self.client, noisy=False)
    21472147        d.addCallback(lambda ign: self.assertEquals(self.result, self.expected))
    21482148        return d
     2149
     2150    def testFetchBodyPartOfNonMultipart(self):
     2151        self.function = self.client.fetchBodyParts
     2152        self.messages = '1'
     2153        parts = [1]
     2154        outerBody = 'DA body'
     2155        headers = util.OrderedDict()
     2156        headers['from'] = 'sender@host'
     2157        headers['to'] = 'recipient@domain'
     2158        headers['subject'] = 'booga booga boo'
     2159        headers['content-type'] = 'text/plain'
     2160        self.msgObjs = [FakeyMessage(
     2161            headers, (), None, outerBody, 123, None)]
     2162
     2163        self.expected = {
     2164            0: {'1': outerBody},
     2165        }
     2166
     2167        def result(R):
     2168            self.result = R
     2169
     2170        self.connected.addCallback(lambda _: self.function(self.messages, parts))
     2171        self.connected.addCallback(result)
     2172        self.connected.addCallback(self._cbStopClient)
     2173        self.connected.addErrback(self._ebGeneral)
     2174
     2175        d = loopback.loopbackTCP(self.server, self.client, noisy=False)
     2176        d.addCallback(lambda ign: self.assertEquals(self.result, self.expected))
     2177        return d
    21492178 
    21502179    def testFetchSize(self, uid=0):
    21512180        self.function = self.client.fetchSize