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
This commit is contained in:
2026-06-23 07:07:28 +00:00
committed by didericis
parent cb3bb209d6
commit a1aa8feb85
3 changed files with 16 additions and 14 deletions
@@ -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.backend.docker.bottle_plan import DockerBottlePlan
from bot_bottle.egress import EgressPlan from bot_bottle.egress import EgressPlan
from bot_bottle.git_gate import GitGatePlan from bot_bottle.git_gate import GitGatePlan
from bot_bottle.manifest import Manifest from bot_bottle.manifest import ManifestIndex
_SLUG = "dev-abc12" _SLUG = "dev-abc12"
_COMMITTED_TAG = f"bot-bottle-committed-{_SLUG}:latest" _COMMITTED_TAG = f"bot-bottle-committed-{_SLUG}:latest"
_DEFAULT_IMAGE = "bot-bottle-claude:latest" _DEFAULT_IMAGE = "bot-bottle-claude:latest"
_IDX = ManifestIndex.from_json_obj({
def _manifest() -> Manifest: "bottles": {"dev": {}},
return Manifest.from_json_obj({ "agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}},
"bottles": {"dev": {}}, })
"agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}},
})
def _plan(tmp: str) -> DockerBottlePlan: def _plan(tmp: str) -> DockerBottlePlan:
stage = Path(tmp) stage = Path(tmp)
spec = BottleSpec( spec = BottleSpec(
manifest=_manifest(), manifest=_IDX,
agent_name="demo", agent_name="demo",
copy_cwd=False, copy_cwd=False,
user_cwd=tmp, user_cwd=tmp,
@@ -42,6 +40,7 @@ def _plan(tmp: str) -> DockerBottlePlan:
) )
return DockerBottlePlan( return DockerBottlePlan(
spec=spec, spec=spec,
manifest=_IDX.load_for_agent("demo"),
stage_dir=stage, stage_dir=stage,
git_gate_plan=GitGatePlan( git_gate_plan=GitGatePlan(
slug=_SLUG, slug=_SLUG,
+8 -5
View File
@@ -10,8 +10,11 @@ from typing import cast
from unittest.mock import patch from unittest.mock import patch
from bot_bottle.agent_provider import AgentProvisionPlan 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 import launch
from bot_bottle.backend.macos_container.bottle_plan import MacosContainerBottlePlan 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 from bot_bottle.manifest import ManifestIndex
_MANIFEST = ManifestIndex.from_json_obj({ _MANIFEST = ManifestIndex.from_json_obj({
@@ -264,11 +267,11 @@ class TestMacosContainerLaunchArgv(unittest.TestCase):
def _build_plan(stage_dir: Path) -> MacosContainerBottlePlan: def _build_plan(stage_dir: Path) -> MacosContainerBottlePlan:
return MacosContainerBottlePlan( return MacosContainerBottlePlan(
spec=SimpleNamespace(), spec=cast(BottleSpec, SimpleNamespace()),
manifest=_MANIFEST, manifest=_MANIFEST,
stage_dir=stage_dir, stage_dir=stage_dir,
git_gate_plan=SimpleNamespace(upstreams=()), git_gate_plan=cast(GitGatePlan, SimpleNamespace(upstreams=())),
egress_plan=SimpleNamespace(), egress_plan=cast(EgressPlan, SimpleNamespace()),
supervise_plan=None, supervise_plan=None,
agent_provision=AgentProvisionPlan( agent_provision=AgentProvisionPlan(
template="claude", template="claude",
@@ -298,7 +301,7 @@ class TestMacosContainerLaunchCommittedImage(unittest.TestCase):
plan = _build_plan(self.stage_dir) plan = _build_plan(self.stage_dir)
calls = [] calls = []
def fake_build(image, context, *, dockerfile=""): def fake_build(image: str, context: str, *, dockerfile: str = "") -> None:
calls.append((image, context, dockerfile)) calls.append((image, context, dockerfile))
with patch.object( with patch.object(
@@ -319,7 +322,7 @@ class TestMacosContainerLaunchCommittedImage(unittest.TestCase):
plan = _build_plan(self.stage_dir) plan = _build_plan(self.stage_dir)
calls = [] calls = []
def fake_build(image, context, *, dockerfile=""): def fake_build(image: str, context: str, *, dockerfile: str = "") -> None:
calls.append((image, context, dockerfile)) calls.append((image, context, dockerfile))
with patch.object( with patch.object(
+1 -1
View File
@@ -79,7 +79,7 @@ resolver #2
) )
dockerfile_text = "" 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 nonlocal dockerfile_text
with open(dockerfile, encoding="utf-8") as f: with open(dockerfile, encoding="utf-8") as f:
dockerfile_text = f.read() dockerfile_text = f.read()