Exemplo n.º 1
0
 def test_errReceived(self):
     """
     L{LocalWorker.errReceived} logs the errors into its C{_errLog} log
     file.
     """
     fakeTransport = FakeTransport()
     localWorker = LocalWorker(FakeAMProtocol(), '.', 'test.log')
     localWorker.makeConnection(fakeTransport)
     localWorker._errLog = BytesIO()
     data = b"The quick brown fox jumps over the lazy dog"
     localWorker.errReceived(data)
     self.assertEqual(data, localWorker._errLog.getvalue())
Exemplo n.º 2
0
 def test_errReceived(self):
     """
     L{LocalWorker.errReceived} logs the errors into its C{_errLog} log
     file.
     """
     fakeTransport = FakeTransport()
     localWorker = LocalWorker(FakeAMProtocol(), '.', 'test.log')
     localWorker.makeConnection(fakeTransport)
     localWorker._errLog = StringIO()
     data = "The quick brown fox jumps over the lazy dog"
     localWorker.errReceived(data)
     self.assertEqual(data, localWorker._errLog.getvalue())
Exemplo n.º 3
0
    def test_connectionLost(self):
        """
        L{LocalWorker.connectionLost} closes the log streams.
        """
        class FakeStream(object):
            callNumber = 0

            def close(self):
                self.callNumber += 1

        transport = FakeTransport()
        localWorker = LocalWorker(FakeAMProtocol(), '.', 'test.log')
        localWorker.makeConnection(transport)
        localWorker._outLog = FakeStream()
        localWorker._errLog = FakeStream()
        localWorker.connectionLost(None)
        self.assertEqual(localWorker._outLog.callNumber, 1)
        self.assertEqual(localWorker._errLog.callNumber, 1)
Exemplo n.º 4
0
    def test_connectionLost(self):
        """
        L{LocalWorker.connectionLost} closes the log streams.
        """

        class FakeStream(object):
            callNumber = 0

            def close(self):
                self.callNumber += 1


        transport = FakeTransport()
        localWorker = LocalWorker(FakeAMProtocol(), '.', 'test.log')
        localWorker.makeConnection(transport)
        localWorker._outLog = FakeStream()
        localWorker._errLog = FakeStream()
        localWorker.connectionLost(None)
        self.assertEqual(localWorker._outLog.callNumber, 1)
        self.assertEqual(localWorker._errLog.callNumber, 1)