Repository navigation
Expand file tree
/
Copy pathcli-history-command-modularization-smoke.py
More file actions
63 lines (47 loc) · 2.11 KB
/
Copy pathcli-history-command-modularization-smoke.py
File metadata and controls
63 lines (47 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
return subprocess.run(
[sys.executable, "-m", "loopx.cli", *args],
cwd=ROOT,
text=True,
capture_output=True,
check=False,
)
def assert_contains(text: str, needle: str) -> None:
if needle not in text:
raise AssertionError(f"expected to find {needle!r} in output:\n{text}")
def assert_not_contains(text: str, needle: str) -> None:
if needle in text:
raise AssertionError(f"did not expect to find {needle!r} in output:\n{text}")
def main() -> int:
cli_source = (ROOT / "loopx" / "cli.py").read_text(encoding="utf-8")
init_source = (ROOT / "loopx" / "cli_commands" / "__init__.py").read_text(
encoding="utf-8"
)
history_source = (ROOT / "loopx" / "cli_commands" / "history.py").read_text(
encoding="utf-8"
)
if "history_parser = sub.add_parser" in cli_source:
raise AssertionError("history parser registration leaked back into loopx/cli.py")
assert_contains(cli_source, "register_history_command(sub)")
assert_contains(cli_source, "handle_history_command(")
assert_contains(init_source, "register_history_command")
assert_contains(init_source, "handle_history_command")
assert_not_contains(history_source, "append_active_user_assisted_pilot")
assert_contains(history_source, "render_index_duplicate_repair_markdown")
help_result = run_cli("history", "--help")
if help_result.returncode != 0:
raise AssertionError(help_result.stderr or help_result.stdout)
assert_not_contains(help_result.stdout, "append-active-user-assisted-pilot")
assert_contains(help_result.stdout, "repair-index-duplicates")
assert_contains(help_result.stdout, "rebuild-index-collisions")
assert_not_contains(help_result.stdout, "--active-user-pilot-json")
print("cli-history-command-modularization-smoke: ok")
return 0
if __name__ == "__main__":
raise SystemExit(main())

