Keep run-once timeout flag distinct

This commit is contained in:
rob
2026-09-29 13:15:29 -03:00
parent a2f95b5dd9
commit a37a13f77a
2 changed files with 50 additions and 1 deletions
-1
View File
@@ -124,7 +124,6 @@ def main():
p_run_once.add_argument("--data-classification", choices=["public", "internal", "private"]) p_run_once.add_argument("--data-classification", choices=["public", "internal", "private"])
p_run_once.add_argument("--require-model-identity", action="store_true") p_run_once.add_argument("--require-model-identity", action="store_true")
p_run_once.add_argument("--require-model-digest", action="store_true") p_run_once.add_argument("--require-model-digest", action="store_true")
p_run_once.add_argument("--provider-timeout", type=int, help="Seconds each AI provider call may take")
p_run_once.add_argument("--result-envelope", choices=["json"]) p_run_once.add_argument("--result-envelope", choices=["json"])
p_run_once.set_defaults(func=cmd_run_once) p_run_once.set_defaults(func=cmd_run_once)
+50
View File
@@ -216,6 +216,20 @@ class TestRunOnceCommand:
assert call_provider.call_args.args[1] == "Summarize this\n\ndocument body" assert call_provider.call_args.args[1] == "Summarize this\n\ndocument body"
def test_timeout_reaches_provider_call(self):
result = SimpleNamespace(success=True, text="ok", error=None)
with (
patch('sys.argv', [
'cmdforge', 'run-once', 'hello', '--provider', 'mock',
'--timeout', '145',
]),
patch('sys.stdin', StringIO()),
patch('cmdforge.providers.call_provider', return_value=result) as call_provider,
):
assert main() == 0
assert call_provider.call_args.kwargs["timeout"] == 145
def test_uses_configured_default_provider(self): def test_uses_configured_default_provider(self):
result = SimpleNamespace(success=True, text="ok", error=None) result = SimpleNamespace(success=True, text="ok", error=None)
config = SimpleNamespace(default_provider="configured-provider") config = SimpleNamespace(default_provider="configured-provider")
@@ -294,6 +308,42 @@ class TestRunOnceCommand:
assert call["fallback_used"] is False assert call["fallback_used"] is False
class TestRunCommand:
def test_provider_timeout_reaches_prompt_step_provider_call(self):
from cmdforge.providers import ProviderResult
tool = Tool(
name="timeout-tool",
steps=[PromptStep(
prompt="Process {input}",
provider="mock",
output_var="result",
plain_text=True,
timeout=900,
)],
output="{result}",
)
stdin = MagicMock()
stdin.isatty.return_value = True
with (
patch('sys.argv', [
'cmdforge', 'run', 'timeout-tool', '--provider-timeout', '145',
]),
patch('sys.stdin', stdin),
patch(
'cmdforge.cli.tool_commands._resolve_existing_tool',
return_value=tool,
),
patch(
'cmdforge.runner.call_provider',
return_value=ProviderResult(text="ok", success=True),
) as call_provider,
):
assert main() == 0
assert call_provider.call_args.kwargs["timeout"] == 145
class TestCreateCommand: class TestCreateCommand:
"""Tests for 'cmdforge create' command.""" """Tests for 'cmdforge create' command."""