def testGetWithDir(self): tmpdir = utils.get_tmp_dir() origpath = os.path.join(tmpdir, 'testGetWithDir') os.mkdir(origpath) dstpath = utils.get(origpath) self.assertTrue(dstpath.endswith('/')) self.assertTrue(os.path.isdir(dstpath))
def testInstallFromDir(self): class MockInstallHost: def __init__(self): self.commands = [] self.hostname = 'autotest-client.foo.com' def run(self, command, ignore_status=False): self.commands.append(command) def send_file(self, src, dst, delete_dest=False): self.commands.append("send_file: %s %s" % (src, dst)) def wait_up(self, timeout): pass def get_autodir(self): pass def set_autodir(self, autodir): pass def setup(self): pass host = MockInstallHost() tmpdir = utils.get_tmp_dir() self.autotest.get(tmpdir) self.autotest.install(host) self.assertEqual(host.commands[0], 'test -x %s/bin/autotest' % _TOP_PATH) self.assertEqual(host.commands[1], 'test -w %s' % _TOP_PATH) self.assertEqual(host.commands[2], 'mkdir -p %s' % _TOP_PATH) self.assertTrue(host.commands[4].startswith('send_file: []')) self.assertTrue(host.commands[4].endswith(_TOP_PATH))
def testGetWithOpenFile(self): tmpdir = utils.get_tmp_dir() tmppath = os.path.join(tmpdir, 'testfile') tmpfile = file(tmppath, 'w') print >> tmpfile, 'Test string' tmpfile.close() tmpfile = file(tmppath) newtmppath = utils.get(tmpfile) self.assertEqual(file(newtmppath).read(), 'Test string\n')