feat(utils): Implement VFSHelper for in-memory artifact management
This commit is contained in:
49
backend/tests/test_vfs.py
Normal file
49
backend/tests/test_vfs.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import pytest
|
||||
from ea_chatbot.utils.vfs import VFSHelper
|
||||
|
||||
def test_vfs_read_write():
|
||||
"""Verify that we can write and read from the VFS."""
|
||||
vfs = {}
|
||||
helper = VFSHelper(vfs)
|
||||
|
||||
helper.write("test.txt", "Hello World", metadata={"type": "text"})
|
||||
assert "test.txt" in vfs
|
||||
assert vfs["test.txt"]["content"] == "Hello World"
|
||||
assert vfs["test.txt"]["metadata"]["type"] == "text"
|
||||
|
||||
content, metadata = helper.read("test.txt")
|
||||
assert content == "Hello World"
|
||||
assert metadata["type"] == "text"
|
||||
|
||||
def test_vfs_list():
|
||||
"""Verify that we can list files in the VFS."""
|
||||
vfs = {}
|
||||
helper = VFSHelper(vfs)
|
||||
|
||||
helper.write("a.txt", "content a")
|
||||
helper.write("b.txt", "content b")
|
||||
|
||||
files = helper.list()
|
||||
assert "a.txt" in files
|
||||
assert "b.txt" in files
|
||||
assert len(files) == 2
|
||||
|
||||
def test_vfs_delete():
|
||||
"""Verify that we can delete files from the VFS."""
|
||||
vfs = {}
|
||||
helper = VFSHelper(vfs)
|
||||
|
||||
helper.write("test.txt", "Hello")
|
||||
helper.delete("test.txt")
|
||||
|
||||
assert "test.txt" not in vfs
|
||||
assert len(helper.list()) == 0
|
||||
|
||||
def test_vfs_not_found():
|
||||
"""Verify that reading a non-existent file returns None."""
|
||||
vfs = {}
|
||||
helper = VFSHelper(vfs)
|
||||
|
||||
content, metadata = helper.read("missing.txt")
|
||||
assert content is None
|
||||
assert metadata is None
|
||||
Reference in New Issue
Block a user