File size: 1,771 Bytes
b31ff59 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import os
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch
import gemini_bot_stack as module
def test_second_bot_uses_remote_models_and_its_own_checkpoint(tmp_path, monkeypatch):
monkeypatch.setattr(module, "ROOT", tmp_path / "runner")
monkeypatch.setattr(module, "VOYAGER_ROOT", tmp_path / "first-runner")
(tmp_path / "first-runner").mkdir()
(tmp_path / "first-runner/.node-ready").write_text("ok\n")
monkeypatch.setattr(module, "CKPT_DIR", tmp_path / "checkpoint")
monkeypatch.setattr(module, "LOG_PATH", tmp_path / "runner/log")
source = tmp_path / "source"
monkeypatch.setattr(module, "VOYAGER_SRC", source)
(source / "voyager/env/mineflayer/node_modules/mineflayer").mkdir(parents=True)
monkeypatch.setenv("GEMINI_BOT_BACKEND", "mine")
monkeypatch.setenv("GEMINI_BOT_KEY_1", "private-value")
bot = module.GeminiBotStack()
bot._pump = lambda *args: None
env = bot._mine_env()
assert "GEMINI_BOT_KEY_1" not in env
proc = SimpleNamespace(pid=99999, poll=lambda: None)
with patch.object(module.subprocess, "Popen", return_value=proc) as launch:
bot._start_voyager(env)
actual = launch.call_args.kwargs["env"]
assert actual["VOYAGER_OPENAI_BASE"] == "https://erinaldordso-mine.hf.space/v1"
assert actual["VOYAGER_MODEL"] == "qwen3-coder-30b-a3b-instruct"
assert actual["VOYAGER_AUX_MODEL"] == "granite-4.0-h-tiny"
assert actual["MINEFLAYER_API_PORT"] == "3001"
assert actual["VOYAGER_CKPT_DIR"] == str(tmp_path / "checkpoint")
assert actual["MC_USERNAME"] == "Gemini_Bot"
assert launch.call_args.kwargs["start_new_session"] is (os.name == "posix")
assert bot.proxy_proc is None
|