From a1aa8feb85fedec8f9125cf109e759bde0ddda8b Mon Sep 17 00:00:00 2001 From: claude Date: Tue, 23 Jun 2026 07:07:28 +0000 Subject: [PATCH] fix: correct Manifest/ManifestIndex usage and add missing type annotations in tests - test_docker_launch_committed_image: replace Manifest.from_json_obj (nonexistent) with ManifestIndex.from_json_obj; pass manifest= arg to DockerBottlePlan constructor (required by BottlePlan base class) - test_macos_container_launch: cast SimpleNamespace stubs to their expected types (BottleSpec, GitGatePlan, EgressPlan) in _build_plan; add str type annotations to fake_build parameter signatures - test_macos_container_util: add str type annotations to fake_build_image parameter signatures --- tests/unit/test_docker_launch_committed_image.py | 15 +++++++-------- tests/unit/test_macos_container_launch.py | 13 ++++++++----- tests/unit/test_macos_container_util.py | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/unit/test_docker_launch_committed_image.py b/tests/unit/test_docker_launch_committed_image.py index be253d7..1152e63 100644 --- a/tests/unit/test_docker_launch_committed_image.py +++ b/tests/unit/test_docker_launch_committed_image.py @@ -16,25 +16,23 @@ from bot_bottle.backend.docker import launch as launch_mod from bot_bottle.backend.docker.bottle_plan import DockerBottlePlan from bot_bottle.egress import EgressPlan from bot_bottle.git_gate import GitGatePlan -from bot_bottle.manifest import Manifest +from bot_bottle.manifest import ManifestIndex _SLUG = "dev-abc12" _COMMITTED_TAG = f"bot-bottle-committed-{_SLUG}:latest" _DEFAULT_IMAGE = "bot-bottle-claude:latest" - -def _manifest() -> Manifest: - return Manifest.from_json_obj({ - "bottles": {"dev": {}}, - "agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}}, - }) +_IDX = ManifestIndex.from_json_obj({ + "bottles": {"dev": {}}, + "agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}}, +}) def _plan(tmp: str) -> DockerBottlePlan: stage = Path(tmp) spec = BottleSpec( - manifest=_manifest(), + manifest=_IDX, agent_name="demo", copy_cwd=False, user_cwd=tmp, @@ -42,6 +40,7 @@ def _plan(tmp: str) -> DockerBottlePlan: ) return DockerBottlePlan( spec=spec, + manifest=_IDX.load_for_agent("demo"), stage_dir=stage, git_gate_plan=GitGatePlan( slug=_SLUG, diff --git a/tests/unit/test_macos_container_launch.py b/tests/unit/test_macos_container_launch.py index 02b29dc..d9ae81c 100644 --- a/tests/unit/test_macos_container_launch.py +++ b/tests/unit/test_macos_container_launch.py @@ -10,8 +10,11 @@ from typing import cast from unittest.mock import patch from bot_bottle.agent_provider import AgentProvisionPlan +from bot_bottle.backend import BottleSpec from bot_bottle.backend.macos_container import launch from bot_bottle.backend.macos_container.bottle_plan import MacosContainerBottlePlan +from bot_bottle.egress import EgressPlan +from bot_bottle.git_gate import GitGatePlan from bot_bottle.manifest import ManifestIndex _MANIFEST = ManifestIndex.from_json_obj({ @@ -264,11 +267,11 @@ class TestMacosContainerLaunchArgv(unittest.TestCase): def _build_plan(stage_dir: Path) -> MacosContainerBottlePlan: return MacosContainerBottlePlan( - spec=SimpleNamespace(), + spec=cast(BottleSpec, SimpleNamespace()), manifest=_MANIFEST, stage_dir=stage_dir, - git_gate_plan=SimpleNamespace(upstreams=()), - egress_plan=SimpleNamespace(), + git_gate_plan=cast(GitGatePlan, SimpleNamespace(upstreams=())), + egress_plan=cast(EgressPlan, SimpleNamespace()), supervise_plan=None, agent_provision=AgentProvisionPlan( template="claude", @@ -298,7 +301,7 @@ class TestMacosContainerLaunchCommittedImage(unittest.TestCase): plan = _build_plan(self.stage_dir) calls = [] - def fake_build(image, context, *, dockerfile=""): + def fake_build(image: str, context: str, *, dockerfile: str = "") -> None: calls.append((image, context, dockerfile)) with patch.object( @@ -319,7 +322,7 @@ class TestMacosContainerLaunchCommittedImage(unittest.TestCase): plan = _build_plan(self.stage_dir) calls = [] - def fake_build(image, context, *, dockerfile=""): + def fake_build(image: str, context: str, *, dockerfile: str = "") -> None: calls.append((image, context, dockerfile)) with patch.object( diff --git a/tests/unit/test_macos_container_util.py b/tests/unit/test_macos_container_util.py index ac98702..d23951f 100644 --- a/tests/unit/test_macos_container_util.py +++ b/tests/unit/test_macos_container_util.py @@ -79,7 +79,7 @@ resolver #2 ) dockerfile_text = "" - def fake_build_image(image_tag, context, *, dockerfile=""): + def fake_build_image(image_tag: str, context: str, *, dockerfile: str = "") -> None: nonlocal dockerfile_text with open(dockerfile, encoding="utf-8") as f: dockerfile_text = f.read()