def test_init_workerdest_old_api_warns(self): with assertProducesWarning( DeprecatedWorkerNameWarning, message_pattern="'slavedest' keyword argument is deprecated"): step = transfer.FileDownload(mastersrc='srcfile', slavedest='dstfile') self.assertEqual(step.workerdest, 'dstfile')
def testBasicWorker2_16(self): master_file = __file__ self.setupStep(transfer.FileDownload(mastersrc=master_file, workerdest=self.destfile), worker_version={'*': '2.16'}) # A place to store what gets read read = [] self.expectCommands( Expect( 'downloadFile', dict(slavedest=self.destfile, workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef(remotetransfer.FileReader))) + Expect.behavior(downloadString(read.append)) + 0) self.expectOutcome(result=SUCCESS, state_string="downloading to {0}".format( os.path.basename(self.destfile))) d = self.runStep() @d.addCallback def checkCalls(res): with open(master_file, "rb") as f: contents = f.read() # Only first 1000 bytes trasferred in downloadString() helper contents = contents[:1000] self.assertEqual(''.join(read), contents) return d
def testBasicWorker2_16(self): master_file = __file__ self.setup_step(transfer.FileDownload(mastersrc=master_file, workerdest=self.destfile), worker_version={'*': '2.16'}) # A place to store what gets read read = [] self.expect_commands( ExpectDownloadFile(slavedest=self.destfile, workdir='wkdir', blocksize=16384, maxsize=None, mode=None, reader=ExpectRemoteRef( remotetransfer.FileReader)).download_string( read.append, size=1000).exit(0)) self.expect_outcome(result=SUCCESS, state_string="downloading to {0}".format( os.path.basename(self.destfile))) yield self.run_step() def checkCalls(res): with open(master_file, "rb") as f: contents = f.read() contents = contents[:1000] self.assertEqual(b''.join(read), contents)
def _fixPermissions(self, source): # Hack for Windows haveChmod = transfer.FileDownload(mastersrc="dependencies/chmod.bat", slavedest="chmod.bat", workdir=".") source.insert(0, haveChmod) # Fix any nasty permissions left over from last time that # might cause the cleanup to fail. fixPermissions = ShellCommand( workdir=".", command=["chmod", "u+rwX", "-f", "-R", "Twisted"]) source.insert(0, fixPermissions)
def test_workerdest_old_api(self): step = transfer.FileDownload(mastersrc='srcfile', workerdest='dstfile') with assertNotProducesWarnings(DeprecatedWorkerAPIWarning): new = step.workerdest with assertProducesWarning( DeprecatedWorkerNameWarning, message_pattern="'slavedest' attribute is deprecated"): old = step.slavedest self.assertIdentical(new, old)
def test_no_file(self): self.setupStep(transfer.FileDownload(mastersrc='not existing file', workerdest=self.destfile)) self.expectCommands() self.expectOutcome(result=FAILURE, state_string="downloading to {0} (failure)".format( os.path.basename(self.destfile))) self.expectLogfile('stderr', "File 'not existing file' not available at master") yield self.runStep()
def test_no_file(self): self.setup_step( transfer.FileDownload(mastersrc='not existing file', workerdest=self.destfile)) self.expect_commands() self.expect_outcome( result=FAILURE, state_string=f"downloading to {os.path.basename(self.destfile)} " "(failure)") self.expect_log_file( 'stderr', "File 'not existing file' not available at master") yield self.run_step()
def test_no_file(self): self.setupStep( transfer.FileDownload(mastersrc='not existing file', workerdest=self.destfile)) self.expectCommands() self.expectOutcome( result=EXCEPTION, state_string="downloading to {0} (exception)".format( os.path.basename(self.destfile))) yield self.runStep() self.expectLogfile('stderr', "File wkdir/srcdir not available at worker") self.assertEqual(len(self.flushLoggedErrors(FileNotFoundError)), 1)
def testAllSteps(self): # make sure that steps can be created from the factories that they # return for s in ( dummy.Dummy(), dummy.FailingDummy(), dummy.RemoteDummy(), maxq.MaxQ("testdir"), python.BuildEPYDoc(), python.PyFlakes(), python_twisted.HLint(), python_twisted.Trial(testpath=None, tests="tests"), python_twisted.ProcessDocs(), python_twisted.BuildDebs(), python_twisted.RemovePYCs(), shell.ShellCommand(), shell.TreeSize(), shell.Configure(), shell.Compile(), shell.Test(), source.CVS("cvsroot", "module"), source.SVN("svnurl"), source.Darcs("repourl"), source.Git("repourl"), source.Arch("url", "version"), source.Bazaar("url", "version", "archive"), source.Bzr("repourl"), source.Mercurial("repourl"), source.P4("p4base"), source.P4Sync(1234, "p4user", "passwd", "client", mode="copy"), source.Monotone("server", "branch"), transfer.FileUpload("src", "dest"), transfer.FileDownload("src", "dest"), ): try: self._loop(s) except: print "error checking %s" % s raise
def test_init_positional_args(self): self.assertRaises(TypeError, lambda: transfer.FileDownload()) self.assertRaises(TypeError, lambda: transfer.FileDownload('srcfile'))
def test_init_workerdest_positional(self): with assertNotProducesWarnings(DeprecatedWorkerAPIWarning): step = transfer.FileDownload('srcfile', 'dstfile') self.assertEqual(step.workerdest, 'dstfile')
def test_init_workerdest_new_api_no_warns(self): with assertNotProducesWarnings(DeprecatedWorkerAPIWarning): step = transfer.FileDownload(mastersrc='srcfile', workerdest='dstfile') self.assertEqual(step.workerdest, 'dstfile')
def test_init_positional_args(self): with self.assertRaises(TypeError): transfer.FileDownload() with self.assertRaises(TypeError): transfer.FileDownload('srcfile')
def test_init_workerdest_positional(self): step = transfer.FileDownload('srcfile', 'dstfile') self.assertEqual(step.workerdest, 'dstfile')
def test_init_workerdest_keyword(self): step = transfer.FileDownload( mastersrc='srcfile', workerdest='dstfile') self.assertEqual(step.workerdest, 'dstfile')