Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def testMessages(self):
     self.output = StringIOWithoutClosing()
     self.transport = internet.protocol.FileWrapper(self.output)
     protocol =  MyVirtualPOP3()
     protocol.makeConnection(self.transport)
     protocol.service = self.factory
     protocol.lineReceived('APOP [email protected] world')
     protocol.lineReceived('UIDL')
     protocol.lineReceived('RETR 1')
     protocol.lineReceived('QUIT')
     if self.output.getvalue() != self.expectedOutput:
         #print `self.output.getvalue()`
         #print `self.expectedOutput`
         raise AssertionError(self.output.getvalue(), self.expectedOutput)
Exemplo n.º 4
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)