def test_transaction(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) fs.mkdir("/tmp") fn = "/tr" with fs.transaction: with fs.open(fn, "wb") as f: f.write(b"not") assert not fs.exists(fn) assert fs.exists(fn) assert fs.cat(fn) == b"not" fs.rm(fn) assert not fs.exists(fn)
def test_transaction(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) fs.mkdir('/tmp') fn = '/tr' with fs.transaction: with fs.open(fn, 'wb') as f: f.write(b'not') assert not fs.exists(fn) assert fs.exists(fn) assert fs.cat(fn) == b'not' fs.rm(fn) assert not fs.exists(fn)
def test_write_big(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw, block_size=1000) fn = '/bigger' with fs.open(fn, 'wb') as f: f.write(b'o' * 500) assert not fs.exists(fn) f.write(b'o' * 1000) fs.invalidate_cache() assert fs.exists(fn) f.write(b'o' * 200) f.flush() assert f.buffer.tell() == 0 assert fs.cat(fn) == b'o' * 1700
def test_write_big(ftp_writable, cache_type): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw, block_size=1000, cache_type=cache_type) fn = "/bigger" with fs.open(fn, "wb") as f: f.write(b"o" * 500) assert not fs.exists(fn) f.write(b"o" * 1000) fs.invalidate_cache() assert fs.exists(fn) f.write(b"o" * 200) f.flush() assert fs.info(fn)["size"] == 1700 assert fs.cat(fn) == b"o" * 1700
def test_write_small(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) with fs.open("/out2", "wb") as f: f.write(b"oi") assert fs.cat("/out2") == b"oi"
def test_basic(ftp): host, port = ftp fs = FTPFileSystem(host, port) assert fs.ls("/", detail=False) == sorted(os.listdir(here)) out = fs.cat("/" + os.path.basename(__file__)) assert out == open(__file__, "rb").read()
def test_write_small(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) with fs.open('/out2', 'wb') as f: f.write(b'oi') assert fs.cat('/out2') == b'oi'