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!"
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!"
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)
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"
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!")
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, [])
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"
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")
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")
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!")
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, [])
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, [])
def do_get_mailing(self, manager): #print "do_get_mailing" return util.getAllPages(manager, 'get_mailing', Mailing.first().id)