Exemple #1
0
 def testPagingWithoutCallback(self):
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(None))
     x = c.remoteForName("foo")
     l = []
     getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     assert ''.join(l[0]) == bigString, "Pages received not equal to pages sent!"
Exemple #2
0
 def testFilePagingWithoutCallback(self):
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("bar", FilePagerizer(self.filename, None))
     x = c.remoteForName("bar")
     l = []
     getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     assert ''.join(
         l[0]) == bigString, "Pages received not equal to pages sent!"
Exemple #3
0
 def getFile2(x, path):            
     def finished(pages):
         data = ''.join(pages)           
         root, ext = os.path.splitext(os.path.basename(path))
         local_path = root + '-new' + ext     
         f = file(local_path, 'wb')        
         f.write(data)                
         print "%d bytes written to %s" % (len(data), local_path)
         
     util.getAllPages(x, "getFile", path).addCallback(finished)
Exemple #4
0
 def testPagingWithCallback(self):
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(finishedCallback, 'hello', value = 10))
     x = c.remoteForName("foo")
     l = []
     getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     assert ''.join(l[0]) == bigString, "Pages received not equal to pages sent!"
     assert callbackArgs == ('hello',), "Completed callback not invoked"
     assert callbackKeyword == {'value': 10}, "Completed callback not invoked"
Exemple #5
0
 def test_pagingWithoutCallback(self):
     """
     Test L{util.StringPager} without a callback.
     """
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(None))
     x = c.remoteForName("foo")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
Exemple #6
0
 def test_pagingWithoutCallback(self):
     """
     Test L{util.StringPager} without a callback.
     """
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(None))
     x = c.remoteForName("foo")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
Exemple #7
0
 def test_filePagingWithoutCallback(self):
     """
     Test L{util.FilePager} without a callback.
     """
     c, s, pump = connectedServerAndClient()
     pagerizer = FilePagerizer(self.filename, None)
     s.setNameForLocal("bar", pagerizer)
     x = c.remoteForName("bar")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
     self.assertEquals(pagerizer.pager.chunks, [])
Exemple #8
0
 def testPagingWithCallback(self):
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(finishedCallback, 'hello',
                                        value=10))
     x = c.remoteForName("foo")
     l = []
     getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     assert ''.join(
         l[0]) == bigString, "Pages received not equal to pages sent!"
     assert callbackArgs == ('hello', ), "Completed callback not invoked"
     assert callbackKeyword == {
         'value': 10
     }, "Completed callback not invoked"
Exemple #9
0
 def test_filePagingWithoutCallback(self):
     """
     Test L{util.FilePager} without a callback.
     """
     c, s, pump = connectedServerAndClient()
     pagerizer = FilePagerizer(self.filename, None)
     s.setNameForLocal("bar", pagerizer)
     x = c.remoteForName("bar")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
     self.assertEquals(pagerizer.pager.chunks, [])
Exemple #10
0
 def test_pagingWithCallback(self):
     """
     Test L{util.StringPager}, passing a callback to fire when all pages
     are sent.
     """
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(finishedCallback, 'hello', value=10))
     x = c.remoteForName("foo")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
     self.assertEquals(callbackArgs, ('hello',),
                       "Completed callback not invoked")
     self.assertEquals(callbackKeyword, {'value': 10},
                       "Completed callback not invoked")
Exemple #11
0
 def test_pagingWithCallback(self):
     """
     Test L{util.StringPager}, passing a callback to fire when all pages
     are sent.
     """
     c, s, pump = connectedServerAndClient()
     s.setNameForLocal("foo", Pagerizer(finishedCallback, 'hello',
                                        value=10))
     x = c.remoteForName("foo")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
     self.assertEquals(callbackArgs, ('hello', ),
                       "Completed callback not invoked")
     self.assertEquals(callbackKeyword, {'value': 10},
                       "Completed callback not invoked")
Exemple #12
0
 def test_emptyFilePaging(self):
     """
     Test L{util.FilePager}, sending an empty file.
     """
     filenameEmpty = self.mktemp()
     fd = file(filenameEmpty, 'w')
     fd.close()
     c, s, pump = connectedServerAndClient()
     pagerizer = FilePagerizer(filenameEmpty, None)
     s.setNameForLocal("bar", pagerizer)
     x = c.remoteForName("bar")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     ttl = 10
     while not l and ttl > 0:
         pump.pump()
         ttl -= 1
     if not ttl:
         self.fail('getAllPages timed out')
     self.assertEquals(''.join(l[0]), '',
                       "Pages received not equal to pages sent!")
Exemple #13
0
 def test_filePagingWithCallback(self):
     """
     Test L{util.FilePager}, passing a callback to fire when all pages
     are sent, and verify that the pager doesn't keep chunks in memory.
     """
     c, s, pump = connectedServerAndClient()
     pagerizer = FilePagerizer(self.filename, finishedCallback,
                               'frodo', value = 9)
     s.setNameForLocal("bar", pagerizer)
     x = c.remoteForName("bar")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
     self.assertEquals(callbackArgs, ('frodo',),
                       "Completed callback not invoked")
     self.assertEquals(callbackKeyword, {'value': 9},
                       "Completed callback not invoked")
     self.assertEquals(pagerizer.pager.chunks, [])
Exemple #14
0
 def test_emptyFilePaging(self):
     """
     Test L{util.FilePager}, sending an empty file.
     """
     filenameEmpty = self.mktemp()
     fd = file(filenameEmpty, 'w')
     fd.close()
     c, s, pump = connectedServerAndClient()
     pagerizer = FilePagerizer(filenameEmpty, None)
     s.setNameForLocal("bar", pagerizer)
     x = c.remoteForName("bar")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     ttl = 10
     while not l and ttl > 0:
         pump.pump()
         ttl -= 1
     if not ttl:
         self.fail('getAllPages timed out')
     self.assertEquals(''.join(l[0]), '',
                       "Pages received not equal to pages sent!")
Exemple #15
0
 def test_filePagingWithCallback(self):
     """
     Test L{util.FilePager}, passing a callback to fire when all pages
     are sent, and verify that the pager doesn't keep chunks in memory.
     """
     c, s, pump = connectedServerAndClient()
     pagerizer = FilePagerizer(self.filename,
                               finishedCallback,
                               'frodo',
                               value=9)
     s.setNameForLocal("bar", pagerizer)
     x = c.remoteForName("bar")
     l = []
     util.getAllPages(x, "getPages").addCallback(l.append)
     while not l:
         pump.pump()
     self.assertEquals(''.join(l[0]), bigString,
                       "Pages received not equal to pages sent!")
     self.assertEquals(callbackArgs, ('frodo', ),
                       "Completed callback not invoked")
     self.assertEquals(callbackKeyword, {'value': 9},
                       "Completed callback not invoked")
     self.assertEquals(pagerizer.pager.chunks, [])
Exemple #16
0
 def do_get_mailing(self, manager):
     #print "do_get_mailing"
     return util.getAllPages(manager, 'get_mailing', Mailing.first().id)