def setUp(self): TestCaseInTempDir.setUp(self) self.server = self.VirtualServer( FatLocalTransport(local_path_to_url('.'))) self.server.start_server() self.addCleanup(self.server.stop_server) self.transport = get_transport(self.server.get_url())
class TestFatLocalTransport(TestCaseInTempDir): def setUp(self): TestCaseInTempDir.setUp(self) self.transport = FatLocalTransport(urlutils.local_path_to_url('.')) def test_writeChunk(self): # writeChunk writes a chunk of data to a file at a given offset. filename = 'foo' self.transport.put_bytes(filename, 'content') self.transport.writeChunk(filename, 1, 'razy') self.assertEqual('crazynt', self.transport.get_bytes(filename)) def test_localRealPath(self): # localRealPath takes a URL-encoded relpath and returns a URL-encoded # absolute path. filename = 'foo bar' escaped_filename = urlutils.escape(filename) self.assertNotEqual(filename, escaped_filename) realpath = self.transport.local_realPath(escaped_filename) self.assertEqual( urlutils.escape(os.path.abspath(filename)), realpath) def test_clone_with_no_offset(self): # FatLocalTransport.clone with no arguments returns a new instance of # FatLocalTransport with the same base URL. transport = self.transport.clone() self.assertIsNot(self.transport, transport) self.assertEqual(self.transport.base, transport.base) self.assertIsInstance(transport, FatLocalTransport) def test_clone_with_relative_offset(self): # FatLocalTransport.clone with an offset path returns a new instance # of FatLocalTransport with a base URL equal to the offset path # relative to the old base. transport = self.transport.clone("foo") self.assertIsNot(self.transport, transport) self.assertEqual( urlutils.join(self.transport.base, "foo").rstrip('/'), transport.base.rstrip('/')) self.assertIsInstance(transport, FatLocalTransport) def test_clone_with_absolute_offset(self): transport = self.transport.clone("/") self.assertIsNot(self.transport, transport) self.assertEqual('file:///', transport.base) self.assertIsInstance(transport, FatLocalTransport)
def setUp(self): TestCaseInTempDir.setUp(self) self.transport = FatLocalTransport(urlutils.local_path_to_url('.'))
def setUp(self): TestCaseInTempDir.setUp(self) SFTPTestMixin.setUp(self) transport = AsyncTransport( FatLocalTransport(urlutils.local_path_to_url('.'))) self.sftp_server = TransportSFTPServer(transport)