gabriel / muse public
test_domain_command_registry_wiring.py python
102 lines 4.0 KB
Raw
sha256:c0eba5ad689cec79f4a3fcdc4f5da78556cb4b8cb7b330f944634356c10379ed chore: pivot to nightly channel — bump version to 0.2.0.dev… Sonnet 5 patch 12 days ago
1 """Integration tests for the real CLI wiring into domain_command_registry —
2 muse#74 Phase 2 (SCR_04-07).
3
4 Unlike test_domain_command_registry.py (pure unit tests of the registry
5 contract using arbitrary fixture data), these tests invoke the real CLI
6 via CliRunner and assert on what the actual argparse tree — `muse code`,
7 `muse mist`, `muse social` — populates. `main()` must build the full
8 parser tree to parse argv regardless of which command actually runs, so
9 any invocation (even an unrelated one) populates the registry.
10
11 Assertions use membership + a count floor, never an exact list — an
12 exact list here would just be a second hardcoded array, the exact
13 failure mode this issue exists to eliminate.
14 """
15
16 from tests.cli_test_helper import CliRunner
17
18 from muse.cli.domain_command_registry import get_supported_commands
19
20 runner = CliRunner()
21
22
23 def _touch_cli() -> None:
24 """Invoke the CLI once so main() builds the full parser tree.
25
26 Any command works — --version is the cheapest one that always
27 succeeds regardless of CWD or repo state.
28 """
29 result = runner.invoke(None, ["--version"])
30 assert result.exit_code == 0, result.output
31
32
33 class TestCodeNamespaceWiring:
34 def test_contains_stable_known_anchors(self) -> None:
35 _touch_cli()
36 commands = get_supported_commands("code")
37 for anchor in ("grep", "impact", "symbols", "gravity", "hotspots"):
38 assert anchor in commands, f"{anchor!r} missing from muse code's registered commands"
39
40 def test_has_more_than_30_entries(self) -> None:
41 _touch_cli()
42 commands = get_supported_commands("code")
43 assert len(commands) > 30, (
44 f"only {len(commands)} code commands registered — "
45 "expected 30+ real muse code subcommands, not a short hardcoded stand-in"
46 )
47
48 def test_does_not_contain_universal_muse_commands(self) -> None:
49 # "commit"/"diff"/"merge" are top-level `muse <verb>` commands, not
50 # `muse code <verb>` subcommands — they must not leak into this
51 # namespace's registered list.
52 _touch_cli()
53 commands = get_supported_commands("code")
54 assert "commit" not in commands
55 assert "merge" not in commands
56
57
58 class TestMistNamespaceWiring:
59 def test_contains_mist_specific_commands(self) -> None:
60 _touch_cli()
61 commands = get_supported_commands("mist")
62 for anchor in ("create", "fork", "embed", "delete", "update"):
63 assert anchor in commands, f"{anchor!r} missing from muse mist's registered commands"
64
65 def test_does_not_contain_universal_muse_commands(self) -> None:
66 # Proves the registry captures the dedicated `muse mist <verb>`
67 # namespace specifically, not every command muse has.
68 _touch_cli()
69 commands = get_supported_commands("mist")
70 assert "commit" not in commands
71 assert "diff" not in commands
72 assert "merge" not in commands
73 assert "log" not in commands
74 assert "status" not in commands
75
76
77 class TestSocialNamespaceWiring:
78 def test_contains_social_specific_commands(self) -> None:
79 _touch_cli()
80 commands = get_supported_commands("social")
81 for anchor in ("post", "follow", "timeline", "profile"):
82 assert anchor in commands, f"{anchor!r} missing from muse social's registered commands"
83
84 def test_does_not_contain_universal_muse_commands(self) -> None:
85 _touch_cli()
86 commands = get_supported_commands("social")
87 assert "commit" not in commands
88 assert "diff" not in commands
89
90
91 class TestUndeclaredNamespacesReturnEmpty:
92 def test_identity_has_no_dedicated_namespace(self) -> None:
93 _touch_cli()
94 assert get_supported_commands("identity") == []
95
96 def test_scaffold_has_no_dedicated_namespace(self) -> None:
97 _touch_cli()
98 assert get_supported_commands("scaffold") == []
99
100 def test_completely_unknown_name_returns_empty(self) -> None:
101 _touch_cli()
102 assert get_supported_commands("this-domain-does-not-exist") == []
File History 1 commit
sha256:c287f599c5429903a139eadf3c5db5d930520e57cb0c3c575d9570e953c3b2d6 chore: bump version to 0.2.0.dev2 — nightly.2 Sonnet 4.6 patch 11 days ago