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:
@@ -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,
|
||||
|
||||
@@ -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({
|
||||
@@ -269,11 +272,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",
|
||||
@@ -303,7 +306,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(
|
||||
@@ -324,7 +327,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(
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user