fix(system): S61-S62 — API cleanup, drone path routing, naming checker, .backup→.recovery rename (#142)
- API: 18-item P0/P1/P2 cleanup (debug prints→logger, help gate fix, URL injection fix, key masking, unused imports) - Drone: passport walk-up replaces hardcoded src/aipass/<branch> pattern, 13 naming bypasses removed - Seedgo: naming checker fixed (__dunder__ skip + column-0 scope detection) — eliminates 71 false positives system-wide - Spawn: .backup→.recovery rename (pre-change snapshots no longer conflict with backup branch namespace) - .gitignore: .recovery/ added - HERALD.md: Updated through S62 (backup audit, .recovery rename, night shift launch) - README.md: Stats updated (141 PRs, 2900+ tests) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
ae459853f0
commit
6772cacce2
@@ -585,24 +585,52 @@ class TestGitModuleRouting:
|
||||
class TestDetectBranchDir:
|
||||
"""Branch directory detection tests."""
|
||||
|
||||
def test_detects_branch_from_path(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Detects branch name and dir from a path like .../src/aipass/drone/..."""
|
||||
# Simulate CWD being inside a branch
|
||||
fake_path = Path("/home/user/Projects/AIPass/src/aipass/drone/apps/modules")
|
||||
monkeypatch.chdir("/") # Just need a valid dir for the test
|
||||
with patch("aipass.drone.apps.modules.git_module.Path.cwd", return_value=fake_path):
|
||||
detected = _detect_branch_dir()
|
||||
def test_detects_branch_from_passport(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Detects branch name and dir by walking up to .trinity/passport.json."""
|
||||
# Create a fake branch directory with passport
|
||||
branch_dir = tmp_path / "mybranch"
|
||||
trinity = branch_dir / ".trinity"
|
||||
trinity.mkdir(parents=True)
|
||||
passport = trinity / "passport.json"
|
||||
passport.write_text(json.dumps({
|
||||
"branch_info": {"branch_name": "mybranch"},
|
||||
}))
|
||||
|
||||
# CWD is inside a subdirectory of the branch
|
||||
sub_dir = branch_dir / "apps" / "modules"
|
||||
sub_dir.mkdir(parents=True)
|
||||
monkeypatch.chdir(sub_dir)
|
||||
|
||||
detected = _detect_branch_dir()
|
||||
assert detected is not None
|
||||
name, bdir = detected
|
||||
assert name == "drone"
|
||||
assert name == "mybranch"
|
||||
assert bdir == branch_dir.resolve()
|
||||
|
||||
def test_returns_none_for_unrecognized_path(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Returns None when CWD is not under src/aipass/."""
|
||||
"""Returns None when CWD has no .trinity/passport.json above it."""
|
||||
monkeypatch.chdir(tmp_path)
|
||||
detected = _detect_branch_dir()
|
||||
assert detected is None
|
||||
|
||||
def test_detects_non_aipass_branch(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Detects branches outside src/aipass/ (e.g. commons, skills)."""
|
||||
branch_dir = tmp_path / "src" / "commons"
|
||||
trinity = branch_dir / ".trinity"
|
||||
trinity.mkdir(parents=True)
|
||||
passport = trinity / "passport.json"
|
||||
passport.write_text(json.dumps({
|
||||
"branch_info": {"branch_name": "commons"},
|
||||
}))
|
||||
|
||||
monkeypatch.chdir(branch_dir)
|
||||
|
||||
detected = _detect_branch_dir()
|
||||
assert detected is not None
|
||||
name, bdir = detected
|
||||
assert name == "commons"
|
||||
assert bdir == branch_dir.resolve()
|
||||
|
||||
|
||||
class TestGitModuleHelp:
|
||||
"""Help and introspection tests."""
|
||||
|
||||
Reference in New Issue
Block a user