Example #1
0
    def remote_userJoined(self, user, group):
        self.joins.append((user, group))


    def remote_userLeft(self, user, group, reason):
        self.parts.append((user, group, reason))


    def remote_receive(self, sender, recipient, message):
        self.messages.append((sender, recipient, message))


    def remote_groupMetaUpdate(self, group, meta):
        self.meta.append((group, meta))
pb.setUnjellyableForClass(TestMind, service.PBMindReference)


class PBProtocolTestCase(unittest.TestCase):
    def setUp(self):
        self.realm = service.InMemoryWordsRealm("realmname")
        self.checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
        self.portal = portal.Portal(
            self.realm, [self.checker])
        self.serverFactory = pb.PBServerFactory(self.portal)
        self.serverFactory.protocol = self._protocolFactory
        self.serverFactory.unsafeTracebacks = True
        self.clientFactory = pb.PBClientFactory()
        self.clientFactory.unsafeTracebacks = True
        self.serverPort = reactor.listenTCP(0, self.serverFactory)
        self.clientConn = reactor.connectTCP(
Example #2
0
        self.meta = []

    def remote_userJoined(self, user, group):
        self.joins.append((user, group))

    def remote_userLeft(self, user, group, reason):
        self.parts.append((user, group, reason))

    def remote_receive(self, sender, recipient, message):
        self.messages.append((sender, recipient, message))

    def remote_groupMetaUpdate(self, group, meta):
        self.meta.append((group, meta))


pb.setUnjellyableForClass(TestMind, service.PBMindReference)


class PBProtocolTestCase(unittest.TestCase):
    def setUp(self):
        self.realm = service.InMemoryWordsRealm("realmname")
        self.checker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
        self.portal = portal.Portal(self.realm, [self.checker])
        self.serverFactory = pb.PBServerFactory(self.portal)
        self.serverFactory.protocol = self._protocolFactory
        self.serverFactory.unsafeTracebacks = True
        self.clientFactory = pb.PBClientFactory()
        self.clientFactory.unsafeTracebacks = True
        self.serverPort = reactor.listenTCP(0, self.serverFactory)
        self.clientConn = reactor.connectTCP('127.0.0.1',
                                             self.serverPort.getHost().port,
Example #3
0
            meta)

    def userJoined(self, group, user):
        return self.callRemote(
            'userJoined',
            PBGroup(self.realm, self.avatar, group),
            PBUser(self.realm, self.avatar, user))

    def userLeft(self, group, user, reason=None):
        assert reason is None or isinstance(reason, unicode)
        return self.callRemote(
            'userLeft',
            PBGroup(self.realm, self.avatar, group),
            PBUser(self.realm, self.avatar, user),
            reason)
pb.setUnjellyableForClass(PBMind, PBMindReference)


class PBGroup(pb.Referenceable):
    def __init__(self, realm, avatar, group):
        self.realm = realm
        self.avatar = avatar
        self.group = group


    def processUniqueID(self):
        return hash((self.realm.name, self.avatar.name, self.group.name))


    def jellyFor(self, jellier):
        return reflect.qual(self.__class__), self.group.name.encode('utf-8'), jellier.invoker.registerReference(self)