MCPcopy
hub / github.com/github/spec-kit / test_dispatch_with_mock_cli

Method test_dispatch_with_mock_cli

tests/test_workflows.py:1057–1084  ·  view source on GitHub ↗
(self, tmp_path)

Source from the content-addressed store, hash-verified

1055 assert result.output["exit_code"] == 0
1056
1057 def test_dispatch_with_mock_cli(self, tmp_path):
1058 from unittest.mock import patch, MagicMock
1059 from specify_cli.workflows.steps.prompt import PromptStep
1060 from specify_cli.workflows.base import StepContext, StepStatus
1061
1062 step = PromptStep()
1063 ctx = StepContext(
1064 default_integration="claude",
1065 project_root=str(tmp_path),
1066 )
1067 config = {
1068 "id": "ask",
1069 "type": "prompt",
1070 "prompt": "Explain this code",
1071 }
1072
1073 mock_result = MagicMock()
1074 mock_result.returncode = 0
1075 mock_result.stdout = "Here is the explanation"
1076 mock_result.stderr = ""
1077
1078 with patch("specify_cli.workflows.steps.prompt.shutil.which", return_value="/usr/local/bin/claude"), \
1079 patch("subprocess.run", return_value=mock_result):
1080 result = step.execute(config, ctx)
1081
1082 assert result.status == StepStatus.COMPLETED
1083 assert result.output["dispatched"] is True
1084 assert result.output["exit_code"] == 0
1085
1086 def test_dispatch_uses_executable_override_for_fallback_preflight(self, tmp_path, monkeypatch):
1087 """Prompt preflight falls back to build_exec_args() argv[0]."""

Callers

nothing calls this directly

Calls 3

executeMethod · 0.95
PromptStepClass · 0.90
StepContextClass · 0.90

Tested by

no test coverage detected