Prev | Index | Next

Testing example

from twisted.internet import unittest

class ServerTestCase(unittest.TestCase):
    def testServer(self):
        l = []; f = PresenceFactory()
        p = f.buildProtocol(None)
        p.sendLine = l.append
        p.connectionMade()
        p.lineReceived('ISONLINE foo')
        self.assertEquals(l[-1], 'ERROR')
        p.lineReceived('LOGIN foo')
        self.assertEquals(l[-1], 'YES')
        self.failUnless(f.userOnline('foo'))
        # and so on