The platform for continuously improving AI agents.
import io
import zipfile
import pytest
from overbae.core.errors import DatasetError
from overbae.services.datasets.package_contract import inspect_bytes, validate_manifest
pytestmark = pytest.mark.covers("sandbox")
@pytest.mark.parametrize("consumer", [{"type": "chat_train"}, ["chat_train"], 1, True])
def test_malformed_consumer_returns_actionable_validation(consumer):
manifest = {
"version": 1,
"runtime": "sha256:" + "a" * 64,
"steps": [{"name": "Messages", "entrypoint": "transform.py", "consumer": consumer}],
}
with pytest.raises(DatasetError, match="Consumer must be"):
validate_manifest(manifest, {"transform.py": "pass\n"})
@pytest.mark.parametrize(
("files", "detail"),
[
({"transform.py": "def transform(:\n"}, r"transform.py at line 1, column"),
({"manifest.json": '{"version": }'}, r"manifest.json at line 1, column"),
({"nested/manifest.json": "{}"}, "manifest.json at its root"),
],
)
def test_package_errors_identify_the_file_and_repair_location(files, detail):
content = io.BytesIO()
with zipfile.ZipFile(content, "w") as archive:
for name, value in files.items():
archive.writestr(name, value)
with pytest.raises(DatasetError, match=detail):
inspect_bytes(content.getvalue())