2026-06-03 16:47:08 -07:00
|
|
|
import agent.integrations.local as local_mod
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _StubLocalShellBackend:
|
2026-06-29 16:02:55 -04:00
|
|
|
def __init__(self, *, root_dir, virtual_mode, inherit_env):
|
2026-06-03 16:47:08 -07:00
|
|
|
self.root_dir = root_dir
|
2026-06-29 16:02:55 -04:00
|
|
|
self.virtual_mode = virtual_mode
|
2026-06-03 16:47:08 -07:00
|
|
|
self.inherit_env = inherit_env
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_local_sandbox_creates_missing_root_dir(monkeypatch, tmp_path):
|
|
|
|
|
root = tmp_path / "nested" / "openswe-sandbox"
|
|
|
|
|
monkeypatch.setenv("LOCAL_SANDBOX_ROOT_DIR", str(root))
|
|
|
|
|
monkeypatch.setattr(local_mod, "LocalShellBackend", _StubLocalShellBackend)
|
|
|
|
|
|
|
|
|
|
backend = local_mod.create_local_sandbox()
|
|
|
|
|
|
|
|
|
|
assert root.is_dir()
|
|
|
|
|
assert backend.root_dir == str(root)
|
2026-06-29 16:02:55 -04:00
|
|
|
assert backend.virtual_mode is True
|
2026-06-03 16:47:08 -07:00
|
|
|
assert backend.inherit_env is True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_local_sandbox_defaults_to_cwd(monkeypatch, tmp_path):
|
|
|
|
|
monkeypatch.delenv("LOCAL_SANDBOX_ROOT_DIR", raising=False)
|
|
|
|
|
monkeypatch.chdir(tmp_path)
|
|
|
|
|
monkeypatch.setattr(local_mod, "LocalShellBackend", _StubLocalShellBackend)
|
|
|
|
|
|
|
|
|
|
backend = local_mod.create_local_sandbox()
|
|
|
|
|
|
|
|
|
|
assert backend.root_dir == str(tmp_path)
|
2026-06-29 16:02:55 -04:00
|
|
|
assert backend.virtual_mode is True
|