sirus / backend /SQL_Agent /tests /test_tenant_file_toolkit_structured.py
ranilmukesh's picture
Deploy SiRUS SQL Agent backend
a8c9ee8
from types import SimpleNamespace
from backend.SQL_Agent.tenant_file_toolkit import TenantFileToolkit
class _MockStorage:
bucket_name = "ml-bucket"
class _Client:
@staticmethod
def list_objects(bucket, prefix=None, recursive=True):
return [
SimpleNamespace(object_name="tenant_1/files/raw_data.csv", size=1024, last_modified=SimpleNamespace(strftime=lambda _f: "2026-01-01 00:00:00")),
SimpleNamespace(object_name="tenant_1/projects/p1/models/model_v1.joblib", size=2048, last_modified=SimpleNamespace(strftime=lambda _f: "2026-01-01 00:00:00")),
SimpleNamespace(object_name="tenant_1/projects/p1/evaluation/report_v1.md", size=1000, last_modified=SimpleNamespace(strftime=lambda _f: "2026-01-01 00:00:00")),
]
client = _Client()
def test_list_tenant_assets_structured_groups_datasets_models_reports():
toolkit = TenantFileToolkit(storage_service=_MockStorage())
class _RunContext:
session_state = {"tenant_id": "tenant_1"}
result = toolkit.list_tenant_assets_structured(run_context=_RunContext())
assert "datasets" in result
assert "models" in result
assert "reports" in result
assert any(item["path"].endswith("raw_data.csv") for item in result["datasets"])
assert any(item["path"].endswith(".joblib") for item in result["models"])
assert any(item["path"].endswith(".md") for item in result["reports"])