File size: 849 Bytes
2c3c408 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import os
import tiledb.cc as lt
def test_dir(tmp_path):
ctx = lt.Context()
vfs = lt.VFS(ctx)
path = os.path.join(tmp_path, "test_dir")
vfs._create_dir(path)
assert vfs._is_dir(path) is True
assert vfs._dir_size(path) == 0
vfs._remove_dir(path)
assert vfs._is_dir(path) is False
def test_file_handle(tmp_path):
ctx = lt.Context()
vfs = lt.VFS(ctx)
path = os.path.join(tmp_path, "test_file_handle")
fh = lt.FileHandle(ctx, vfs, path, lt.VFSMode.WRITE)
fh._write(b"Hello")
fh = lt.FileHandle(ctx, vfs, path, lt.VFSMode.READ)
assert fh._read(0, 5) == b"Hello"
fh = lt.FileHandle(ctx, vfs, path, lt.VFSMode.APPEND)
fh._write(b", world!")
fh = lt.FileHandle(ctx, vfs, path, lt.VFSMode.READ)
assert fh._read(0, 13) == b"Hello, world!"
assert fh._closed is False
|