314dc03b0d
Moves the orchestrator into bot_bottle/orchestrator/ so one install gets everything. Entry point is now `python -m bot_bottle.orchestrator run`. - Add bot_bottle/orchestrator/ with all 14 modules (verbatim move; internal imports were already relative, so no changes inside orchestrator modules) - Rewrite bootstrap.py: remove the lazy bot_bottle import guard, use direct relative imports from ..contrib.* - Add bot_bottle/contrib/forge/base.py: ScopedForge (read-anywhere / write-scoped) - Add bot_bottle/contrib/gitea/client.py: GiteaClient + GiteaForge (urllib.request only) - Add bot_bottle/contrib/gitea/forge_state.py: ForgeState + SqliteForgeStateStore - Add tests/unit/orchestrator/ (82 tests: 63 migrated + 19 new for contrib modules) Closes #321
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
"""Unit: SubprocessBottleRunner + slugify (injected run fn)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
from collections.abc import Sequence
|
|
|
|
from bot_bottle.orchestrator.runner import SubprocessBottleRunner, slugify
|
|
|
|
|
|
class SlugifyTest(unittest.TestCase):
|
|
def test_basic(self):
|
|
self.assertEqual("impl-didericis-bot-bottle-17",
|
|
slugify("impl-didericis-bot-bottle-17"))
|
|
|
|
def test_collapses_and_strips(self):
|
|
self.assertEqual("a-b-c", slugify(" A_B/C!! "))
|
|
|
|
|
|
class SubprocessRunnerTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.argvs: list[list[str]] = []
|
|
self.envs: list[dict[str, str]] = []
|
|
|
|
def fake_run(argv: Sequence[str], env: dict[str, str]) -> int:
|
|
self.argvs.append(list(argv))
|
|
self.envs.append(dict(env))
|
|
return 0
|
|
|
|
self.runner = SubprocessBottleRunner(
|
|
cli="/x/cli.py", base_env={"PATH": "/bin"}, python="/py", run=fake_run
|
|
)
|
|
|
|
def test_start_argv_and_env(self):
|
|
result = self.runner.start(
|
|
agent="impl", bottles=["claude", "dev"], label="impl-r-17",
|
|
prompt="do it", forge_env={"FORGE_OWNER": "didericis"},
|
|
)
|
|
self.assertEqual("impl-r-17", result.slug)
|
|
argv = self.argvs[0]
|
|
self.assertEqual(["/py", "/x/cli.py", "start", "impl", "--headless",
|
|
"--label", "impl-r-17", "--prompt", "do it",
|
|
"--bottle", "claude", "--bottle", "dev"], argv)
|
|
# forge_env merged over base_env for the child.
|
|
self.assertEqual("didericis", self.envs[0]["FORGE_OWNER"])
|
|
self.assertEqual("/bin", self.envs[0]["PATH"])
|
|
|
|
def test_start_no_bottles_omits_flag(self):
|
|
self.runner.start(agent="impl", bottles=[], label="l", prompt="p", forge_env={})
|
|
self.assertNotIn("--bottle", self.argvs[0])
|
|
|
|
def test_freeze_calls_commit(self):
|
|
self.runner.freeze("slug-1")
|
|
self.assertEqual(["/py", "/x/cli.py", "commit", "slug-1"], self.argvs[0])
|
|
|
|
def test_resume_headless(self):
|
|
r = self.runner.resume("slug-1", "address review")
|
|
self.assertEqual("slug-1", r.slug)
|
|
self.assertEqual(
|
|
["/py", "/x/cli.py", "resume", "slug-1", "--headless", "--prompt",
|
|
"address review"], self.argvs[0])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|