Beispiel #1
0
 def testDeferredChat(self):
     factory = postfix.PostfixTCPMapDeferringDictServerFactory(self.data)
     output = StringIOWithoutClosing()
     transport = internet.protocol.FileWrapper(output)
     protocol = postfix.PostfixTCPMapServer()
     protocol.service = factory
     protocol.factory = factory
     protocol.makeConnection(transport)
     for input, expected_output in self.chat:
         protocol.lineReceived(input)
         self.assertEquals(output.getvalue(), expected_output,
                           'For %r, expected %r but got %r' % (
             input, expected_output, output.getvalue()
             ))
         output.truncate(0)
     protocol.setTimeout(None)
Beispiel #2
0
 def testMessages(self):
     from twisted.mail import protocols
     protocol =  protocols.DomainSMTP()
     protocol.service = self.factory
     protocol.factory = self.factory
     protocol.receivedHeader = spameater
     protocol.makeConnection(self.transport)
     protocol.lineReceived('HELO yyy.com')
     for message in self.messages:
         protocol.lineReceived('MAIL FROM:<%s>' % message[0])
         for target in message[1]:
             protocol.lineReceived('RCPT TO:<%s>' % target)
         protocol.lineReceived('DATA')
         protocol.dataReceived(message[2])
         protocol.lineReceived('.')
     protocol.lineReceived('QUIT')
     if self.mbox != self.factory.domains['baz.com'].messages:
         raise AssertionError(self.factory.domains['baz.com'].messages)
     protocol.setTimeout(None)
Beispiel #3
0
    def testDeferredChat(self):
        factory = postfix.PostfixTCPMapDeferringDictServerFactory(self.data)
        output = StringIOWithoutClosing()
        transport = internet.protocol.FileWrapper(output)

        protocol = postfix.PostfixTCPMapServer()
        protocol.service = factory
        protocol.factory = factory
        protocol.makeConnection(transport)

        for input, expected_output in self.chat:
            protocol.lineReceived(input)
            # self.runReactor(1)
            self.assertEquals(output.getvalue(), expected_output,
                              'For %r, expected %r but got %r' % (
                input, expected_output, output.getvalue()
                ))
            output.truncate(0)
        protocol.setTimeout(None)