Exemple #1
0
def encodeTokens(obj, debug=0):
    from twisted.trial.util import deferredResult
    b = TokenStorageBanana()
    b.debug = debug
    d = b.send(obj)
    deferredResult(d)
    return b.tokens
 def testInsertChars(self):
     deferredResult(self.myClient.wb.addTextBox(20, 20))
     deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
     self.assertEqual(self.myClient.wb.foreignObjectsCount(), 0)
     wb2 = self.myClient2.wb
     self.assertEqual(wb2.foreignObjectsCount(), 1)
     self.assertEqual(wb2.itemcget(wb2.foreignObjects.values()[0], "text"), "fooBarBaz")
Exemple #3
0
def encodeTokens(obj, debug=0):
    from twisted.trial.util import deferredResult
    b = TokenStorageBanana()
    b.debug = debug
    d = b.send(obj)
    deferredResult(d)
    return b.tokens
    def setUp(self):
        self.done = False
        self.cFactory = pb.PBClientFactory()
        self.realm = WBRealm()
        self.realm.server = WbServer()
        self.wbServer = self.realm.server
        self.p = portal.Portal(self.realm)
        self.c = WBChecker()
        self.p.registerChecker(self.c)
        self.sFactory = pb.PBServerFactory(self.p)
        self.sFactory.protocol = WBBroker
        self.server = reactor.listenTCP(28789, self.sFactory)

        self.myClient = Client()
        self.myClient2 = Client()
        self.client = reactor.connectTCP("localhost", 28789, self.cFactory)
        self.client2 = reactor.connectTCP("localhost", 28789, self.cFactory)
        def1 = self.cFactory.login(credentials.UsernamePassword("Waldo","waldo"), client=self.myClient.cc)
        def1.addCallback(self.getRoot, 1)
        def1.addErrback(self.failure, "Error al conectarse el cliente1")
        deferredResult(def1)

        def2 = self.cFactory.login(credentials.UsernamePassword("Matias","matias"), client=self.myClient2.cc)
        def2.addCallback(self.getRoot, 2)
        def2.addErrback(self.failure, "Error al conectarse el cliente2")
        deferredResult(def2)
Exemple #5
0
 def testGetValidUser(self):
     d = self.checker.requestAvatarId(self.credential)
     e = self.checker.requestAvatarId(self.credential2)
     f = self.checker.requestAvatarId(self.credential3)
     deferredResult(d)
     deferredError(e)
     deferredResult(f)
 def testServerStatusClientAdd(self):
     deferredResult(self.myClient.wb.addTextBox(20, 20))
     deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
     ddict = self.wbServer.wbStatus
     for a in ddict.keys():
         self.assert_(self.myClient2.wb.foreignObjects.has_key(a))
         tbox = self.myClient2.wb.foreignObjects[a]
         self.assertEqual(self.myClient2.wb.itemcget(tbox, "text"),ddict[a]["text"])
 def testServerStatusEditText(self):
     deferredResult(self.myClient.wb.addTextBox(20, 20))
     deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
     current = self.myClient.wb.wbCurrent
     dict = self.wbServer.wbStatus[self.wbServer.itemId(3, current)]
     self.assertEqual(dict["text"], "fooBarBaz")
     self.assertEqual(dict["x"], 20)
     self.assertEqual(dict["y"], 20)
     self.assertEqual(dict["owner"].avId, 3)
 def render(self, tag, precompile=False, data=None, setupRequest=lambda r: r, setupContext=lambda c:c):
     ctx = self.setupContext(precompile, setupRequest)
     ctx = setupContext(ctx)
     if precompile:
         return flat.precompile(tag, ctx)
     else:
         try:
             from twisted.trial import util
             from nevow.flat import twist
         except ImportError:
             return flat.flatten(tag, ctx)
         else:
             L = []
             util.deferredResult(twist.deferflatten(tag, ctx, L.append))
             return ''.join(L)
Exemple #9
0
 def render(self,
            tag,
            precompile=False,
            data=None,
            setupRequest=lambda r: r,
            setupContext=lambda c: c):
     ctx = self.setupContext(precompile, setupRequest)
     ctx = setupContext(ctx)
     if precompile:
         return flat.precompile(tag, ctx)
     else:
         try:
             from twisted.trial import util
             from nevow.flat import twist
         except ImportError:
             return flat.flatten(tag, ctx)
         else:
             L = []
             util.deferredResult(twist.deferflatten(tag, ctx, L.append))
             return ''.join(L)
Exemple #10
0
 def testServerStatusClientModify(self):
     deferredResult(self.myClient.wb.addTextBox(20, 20))
     deferredResult(self.myClient.wb.insertChars(self.myClient.wb.wbCurrent, 0, "fooBarBaz"))
     deferredResult(self.myClient.wb.deleteChars(self.myClient.wb.wbCurrent, 3, 5))
     current = self.myClient.wb.wbCurrent
     ddict = self.wbServer.wbStatus[self.wbServer.itemId(3, current)]
     self.assertEqual(self.myClient.wb.itemcget(current, "text"), "fooBaz")
     self.assertEqual(ddict["text"], "fooBaz")
     self.assertEqual(ddict["x"], 20)
     self.assertEqual(ddict["y"], 20)
Exemple #11
0
 def testAddTextBox(self):
     deferredResult(self.myClient.wb.addTextBox(20, 20))
     self.assertEqual(self.myClient.wb.foreignObjectsCount(), 0)
     self.assertEqual(self.myClient2.wb.foreignObjectsCount(), 1)
Exemple #12
0
 def tearDown(self):
     reactor.removeAll()
     deferredResult(self.server.stopListening())
Exemple #13
0
 def testServerStatusClientDisconnect(self):
     deferredResult(self.myClient.disconnect())
     self.assert_(3 not in self.wbServer.wbClients)
Exemple #14
0
 def testServerStatusNewText(self):
     deferredResult(self.myClient.wb.addTextBox(20, 20))
     current = self.myClient.wb.wbCurrent
     self.assert_(self.wbServer.wbStatus.has_key(self.wbServer.itemId(3, current)))