fix. default full review without test execution
This commit is contained in:
@@ -116,7 +116,10 @@ def test_build_install_command_chatgpt_mode_sets_git_checkout_and_review(monkeyp
|
||||
assert f"git checkout --detach {pr.head_sha}" in command
|
||||
assert "resolved_head=\"$(git rev-parse HEAD)\"" in command
|
||||
assert "unset GITEA_TOKEN auth_b64" in command
|
||||
assert "codex exec --json --output-schema /tmp/codex-review-schema.json -o /tmp/codex-review-result.json" in command
|
||||
assert (
|
||||
"codex exec --sandbox danger-full-access --json --output-schema /tmp/codex-review-schema.json "
|
||||
"-o /tmp/codex-review-result.json"
|
||||
) in command
|
||||
assert "review: security --full" in command
|
||||
assert "--output-schema /tmp/codex-review-schema.json" in command
|
||||
assert "-o /tmp/codex-review-result.json" in command
|
||||
@@ -369,6 +372,27 @@ def test_build_exec_review_prompt_falls_back_when_no_extra_text() -> None:
|
||||
assert prompt.startswith("review: review this pull request and report introduced issues.")
|
||||
|
||||
|
||||
def test_build_exec_review_prompt_disables_test_execution_by_default() -> None:
|
||||
prompt = _build_exec_review_prompt(ParsedCommand(name="review", raw="@codex review"), RepoReviewConfig(), _sample_pr())
|
||||
assert "Do not run tests, benchmarks, or other executables." in prompt
|
||||
|
||||
|
||||
def test_build_exec_review_prompt_allows_test_execution_for_tests_mode() -> None:
|
||||
prompt = _build_exec_review_prompt(
|
||||
ParsedCommand(name="review", raw="@codex review tests", mode="tests", mode_explicit=True),
|
||||
RepoReviewConfig(),
|
||||
_sample_pr(),
|
||||
)
|
||||
assert "Tests may be executed for this run" in prompt
|
||||
|
||||
|
||||
def test_apply_repo_default_review_mode_uses_full_when_not_configured() -> None:
|
||||
command = ParsedCommand(name="review", raw="@codex review")
|
||||
cfg = RepoReviewConfig()
|
||||
_apply_repo_default_review_mode(command, cfg)
|
||||
assert command.mode == "full"
|
||||
|
||||
|
||||
def test_apply_repo_default_review_mode_for_review_command() -> None:
|
||||
command = ParsedCommand(name="review", raw="@codex review")
|
||||
cfg = RepoReviewConfig(default_mode="tests")
|
||||
@@ -390,6 +414,22 @@ def test_parse_review_result_from_stdout_artifact_uses_end_marker_after_start()
|
||||
assert parsed["verdict"] == "correct"
|
||||
|
||||
|
||||
def test_parse_review_result_from_stdout_artifact_handles_inline_end_marker() -> None:
|
||||
stdout = (
|
||||
"noise\n"
|
||||
f"{RESULT_START_MARKER}_a\n"
|
||||
'{"verdict":"correct","confidence":0.9,"summary":"ok","findings":[],"markdown_comment":"ok"}'
|
||||
f"{RESULT_END_MARKER}_a\n"
|
||||
)
|
||||
parsed = _parse_review_result_from_stdout_artifact(
|
||||
stdout,
|
||||
result_start_marker=f"{RESULT_START_MARKER}_a",
|
||||
result_end_marker=f"{RESULT_END_MARKER}_a",
|
||||
)
|
||||
assert parsed["verdict"] == "correct"
|
||||
assert parsed["summary"] == "ok"
|
||||
|
||||
|
||||
def test_extract_result_meta_from_codex_stdout_collects_model_and_usage() -> None:
|
||||
settings = get_settings()
|
||||
stdout = "\n".join(
|
||||
|
||||
8
tests/test_repo_config.py
Normal file
8
tests/test_repo_config.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from gitea_codex_bot.services.repo_config import parse_repo_review_config_text
|
||||
|
||||
|
||||
def test_parse_repo_review_config_defaults_to_full_and_no_tests() -> None:
|
||||
cfg = parse_repo_review_config_text("enabled: true\n", configured=True)
|
||||
assert cfg.default_mode == "full"
|
||||
assert cfg.include_tests is False
|
||||
|
||||
Reference in New Issue
Block a user