test_post_land_sync_integration.py
file-level
1
files
1
commits
0
hotspots
0
🧊 dead
0
💥 blast risk
| 1 | """Integration tier §PLS.10 — merge engine + sync helper compose via injected runners.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from tests.support import FakeGitRunner, gh_merged_runner, pls_config |
| 8 | from tools.close_ritual.post_land_sync import EDITOR_BUFFER_NOTE |
| 9 | from tools.close_ritual.pr_land import EXIT_OK, run_pr_land |
| 10 | |
| 11 | |
| 12 | def test_successful_merge_then_ff_only_pull_reports_synced(repo_root: Path) -> None: |
| 13 | git = FakeGitRunner(branch="feat/pls-a") |
| 14 | result = run_pr_land( |
| 15 | "7", |
| 16 | authorization="operator: land PLS", |
| 17 | runner=gh_merged_runner(), |
| 18 | sleep_fn=lambda _s: None, |
| 19 | repo_root=repo_root, |
| 20 | config=pls_config(repo_root), |
| 21 | git_runner=git, |
| 22 | ) |
| 23 | assert result.exit_code == EXIT_OK |
| 24 | assert result.merged is True |
| 25 | assert result.post_land_sync["status"] == "synced" |
| 26 | assert result.post_land_sync["remote"] == "origin" |
| 27 | assert result.post_land_sync["main_branch"] == "main" |
| 28 | # Mocked main tip updated via fetch + ff-only pull argv (frozen §PLS.4.2). |
| 29 | assert ["git", "fetch", "origin"] in git.calls |
| 30 | assert ["git", "pull", "--ff-only", "origin", "main"] in git.calls |
| 31 | # Editor-buffer note present in both message surfaces (§PLS.4.4 / §PLS.6.3). |
| 32 | assert EDITOR_BUFFER_NOTE in result.post_land_sync["messages"] |
| 33 | assert EDITOR_BUFFER_NOTE in result.messages |
| 34 | |
| 35 | |
| 36 | def test_already_merged_path_also_invokes_sync_when_enabled(repo_root: Path) -> None: |
| 37 | git = FakeGitRunner(branch="main") |
| 38 | result = run_pr_land( |
| 39 | "7", |
| 40 | authorization="operator: re-run after land", |
| 41 | runner=gh_merged_runner(pr_state="MERGED"), |
| 42 | sleep_fn=lambda _s: None, |
| 43 | repo_root=repo_root, |
| 44 | config=pls_config(repo_root), |
| 45 | git_runner=git, |
| 46 | ) |
| 47 | assert result.exit_code == EXIT_OK |
| 48 | assert result.already_merged is True |
| 49 | assert result.post_land_sync["status"] == "synced" |
| 50 | assert ["git", "fetch", "origin"] in git.calls |
| 51 | assert ["git", "pull", "--ff-only", "origin", "main"] in git.calls |
| 52 | |
| 53 | |
| 54 | def test_muse_git_mirror_regime_runs_git_side_only(repo_root: Path) -> None: |
| 55 | git = FakeGitRunner(branch="main") |
| 56 | result = run_pr_land( |
| 57 | "7", |
| 58 | authorization="operator: land", |
| 59 | runner=gh_merged_runner(), |
| 60 | sleep_fn=lambda _s: None, |
| 61 | repo_root=repo_root, |
| 62 | config=pls_config(repo_root, "config-muse-git-mirror.yaml"), |
| 63 | git_runner=git, |
| 64 | ) |
| 65 | assert result.post_land_sync["status"] == "synced" |
| 66 | # Git side only — never Muse commits, bridge export, or muse pull (§PLS.5.3). |
| 67 | assert all(call[0] == "git" for call in git.calls) |