This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import tarfile
|
||||
import unittest
|
||||
|
||||
from agent_builder.tools import (
|
||||
_assert_current_agent_project,
|
||||
_assert_current_a2a_init_template,
|
||||
_render_a2a_init_template,
|
||||
)
|
||||
@@ -35,3 +38,23 @@ class TemplateInitTests(unittest.TestCase):
|
||||
"agent.py": "from a2a_pack import A2AAgent",
|
||||
"requirements.txt": "httpx>=0.27",
|
||||
})
|
||||
|
||||
def test_stale_agent_project_is_rejected(self) -> None:
|
||||
bundle = _tarball({
|
||||
"agent.py": "from a2a_pack import A2AAgent\n",
|
||||
"requirements.txt": "httpx>=0.27\n",
|
||||
})
|
||||
|
||||
with self.assertRaisesRegex(RuntimeError, "agent project is stale"):
|
||||
_assert_current_agent_project(bundle)
|
||||
|
||||
|
||||
def _tarball(files: dict[str, str]) -> bytes:
|
||||
buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=buf, mode="w:gz") as tf:
|
||||
for path, text in files.items():
|
||||
body = text.encode("utf-8")
|
||||
info = tarfile.TarInfo(path)
|
||||
info.size = len(body)
|
||||
tf.addfile(info, io.BytesIO(body))
|
||||
return buf.getvalue()
|
||||
|
||||
Reference in New Issue
Block a user