Minecraft-Friends-AI-ZeroGPU / tests /test_second_bot_mine_backend.py
Erinaldordso's picture
Repair Voyager deadlines and connect both bots to Mine
b31ff59 verified
Raw History Blame Contribute Delete
1.77 kB
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