Files
oh-my-pi/packages/coding-agent/test/tools/python-execution.test.ts
T
can1357 ef415e863b feat(coding-agent): refactored settings system with new singleton API and unified schema
- Replaced SettingsManager class with new Settings singleton providing synchronous get/set API and background persistence.
- Introduced settings-schema.ts as single source of truth for all configuration definitions with 100+ settings organized into logical groups.
- Migrated from method-based settings access (getTheme(), setTheme()) to path-based access using dot notation (settings.get('theme'), settings.set('theme', value)).
- Removed 2035-line settings-manager.ts file and replaced with modular settings.ts (693 lines) and settings-schema.ts (836 lines) for improved maintainability.
- Unified settings schema into single source of truth eliminating duplicate definitions across settings-defs.ts and settings-manager.ts.
2026-02-01 08:08:58 +01:00

65 lines
1.8 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
import * as pythonExecutor from "@oh-my-pi/pi-coding-agent/ipy/executor";
import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { PythonTool } from "@oh-my-pi/pi-coding-agent/tools/python";
import { TempDir } from "@oh-my-pi/pi-utils";
function createSession(cwd: string): ToolSession {
return {
cwd,
hasUI: false,
getSessionFile: () => "session-file",
getSessionSpawns: () => "*",
settings: Settings.isolated({
"lsp.formatOnWrite": true,
"bashInterceptor.enabled": true,
"python.toolMode": "ipy-only",
"python.kernelMode": "per-call",
}),
};
}
describe("python tool execution", () => {
it("passes kernel options from settings and args", async () => {
const tempDir = TempDir.createSync("@python-tool-");
const executeSpy = vi.spyOn(pythonExecutor, "executePython").mockResolvedValue({
output: "ok",
exitCode: 0,
cancelled: false,
truncated: false,
totalLines: 1,
totalBytes: 2,
outputLines: 1,
outputBytes: 2,
displayOutputs: [],
stdinRequested: false,
});
const tool = new PythonTool(createSession(tempDir.path()));
const result = await tool.execute(
"call-id",
{ cells: [{ code: "print('hi')" }], timeout: 5, cwd: tempDir.path(), reset: true },
undefined,
undefined,
undefined,
);
expect(executeSpy).toHaveBeenCalledWith(
"print('hi')",
expect.objectContaining({
cwd: tempDir.path(),
timeoutMs: 5000,
sessionId: `session:session-file:cwd:${tempDir.path()}`,
kernelMode: "per-call",
reset: true,
}),
);
const text = result.content.find(item => item.type === "text")?.text;
expect(text).toBe("ok");
executeSpy.mockRestore();
tempDir.removeSync();
});
});