Option C Tools
Loading...
Searching...
No Matches
tests_mcp.test_contract_parity Namespace Reference

Functions

 test_registry_parity ()
 test_minimal_args_covers_all_tools ()
 test_model_validates_minimal_args (str tool_name, Path tmp_path)
 test_argv_starts_with_expected_subcommand (str tool_name, Path tmp_path)
list[str] _build_cmd (str tool_name, Path tmp_path)
 test_skeleton_does_not_emit_output_dir (Path tmp_path)
 test_deps_does_not_emit_check (Path tmp_path)
 test_test_does_not_emit_jobs (Path tmp_path)
 test_diag_does_not_emit_json (Path tmp_path)
 test_format_does_not_emit_jobs (Path tmp_path)
 test_git_commit_accepts_valid_conventional_messages (str message, Path tmp_path)

Variables

dict _MINIMAL_ARGS
dict _EXPECTED_SUBCOMMAND

Detailed Description

Purpose
-------
OI-502 / FS-502 — MCP contract parity harness. The validator's
``_TOOL_MODEL_MAP`` and the executor's ``_ARGV_BUILDERS`` must register
the same set of tool names, and each registered tool must be executable
against a realistic validated-args dict without tripping the executor's
``.get()`` defaults into producing a CLI flag that the real ``oct`` CLI
does not accept.

The test exercises three invariants:

1. **Registry parity** — ``set(_TOOL_MODEL_MAP) == set(_ARGV_BUILDERS)``.
2. **Per-tool argv well-formed** — for every tool, instantiate the model
   with sensible defaults, call its argv builder, and check the first
   four elements match ``[sys.executable, "-m", "oct", <subcommand>]``.
3. **No spurious flags** — for a curated list of previously-drifting
   flags (``--output-dir``, ``--check``, ``--jobs`` on ``oct test``,
   ``--json`` on ``oct diag``) the argv must *not* contain the flag.
   Regression coverage for the bugs this harness was introduced to fix.

The harness is intentionally static — it does not spawn the ``oct`` CLI
or compare against ``--help`` output, so it runs fast and works even in
environments where click or pytest are missing.

Responsibilities
----------------
- Verify registry parity between ``_TOOL_MODEL_MAP`` and
  ``_ARGV_BUILDERS``.
- Verify per-tool argv starts with
  ``[sys.executable, "-m", "oct", <subcommand>]``.
- Verify previously-drifting flags do not appear in builder output.

Diagnostics
-----------
Domain: MCP-TESTS
Levels:
    L2 — test lifecycle
    L3 — assertion details
    L4 — deep tracing

Contracts
---------
- The parity test must fail if a new tool is added to one registry and
  not the other.
- The spurious-flag checks must fail if a previously-fixed executor
  regression is re-introduced.

Function Documentation

◆ _build_cmd()

list[str] tests_mcp.test_contract_parity._build_cmd ( str tool_name,
Path tmp_path )
protected

Definition at line 166 of file test_contract_parity.py.

Here is the caller graph for this function:

◆ test_argv_starts_with_expected_subcommand()

tests_mcp.test_contract_parity.test_argv_starts_with_expected_subcommand ( str tool_name,
Path tmp_path )
Builder output must begin with python -m oct <subcommand>.

Definition at line 144 of file test_contract_parity.py.

◆ test_deps_does_not_emit_check()

tests_mcp.test_contract_parity.test_deps_does_not_emit_check ( Path tmp_path)
OI-502: CLI ``oct deps`` does not accept ``--check``.

Definition at line 179 of file test_contract_parity.py.

Here is the call graph for this function:

◆ test_diag_does_not_emit_json()

tests_mcp.test_contract_parity.test_diag_does_not_emit_json ( Path tmp_path)
OI-502: no ``oct diag`` subcommand accepts ``--json`` (yet).

Definition at line 191 of file test_contract_parity.py.

Here is the call graph for this function:

◆ test_format_does_not_emit_jobs()

tests_mcp.test_contract_parity.test_format_does_not_emit_jobs ( Path tmp_path)
OI-502: ``oct format`` argparser does not register ``--jobs``.

Definition at line 197 of file test_contract_parity.py.

Here is the call graph for this function:

◆ test_git_commit_accepts_valid_conventional_messages()

tests_mcp.test_contract_parity.test_git_commit_accepts_valid_conventional_messages ( str message,
Path tmp_path )
OI-502 / FS-502 — scoped and breaking commits must round-trip.

Definition at line 217 of file test_contract_parity.py.

◆ test_minimal_args_covers_all_tools()

tests_mcp.test_contract_parity.test_minimal_args_covers_all_tools ( )
_MINIMAL_ARGS must cover every registered tool.

Definition at line 128 of file test_contract_parity.py.

◆ test_model_validates_minimal_args()

tests_mcp.test_contract_parity.test_model_validates_minimal_args ( str tool_name,
Path tmp_path )
Minimal args dict must validate against the registered model.

Definition at line 136 of file test_contract_parity.py.

◆ test_registry_parity()

tests_mcp.test_contract_parity.test_registry_parity ( )
Every validator model must have a matching executor argv builder.

Definition at line 117 of file test_contract_parity.py.

◆ test_skeleton_does_not_emit_output_dir()

tests_mcp.test_contract_parity.test_skeleton_does_not_emit_output_dir ( Path tmp_path)
OI-502: CLI ``oct export-skeleton`` does not accept ``--output-dir``.

Definition at line 173 of file test_contract_parity.py.

Here is the call graph for this function:

◆ test_test_does_not_emit_jobs()

tests_mcp.test_contract_parity.test_test_does_not_emit_jobs ( Path tmp_path)
OI-502: CLI ``oct test`` does not accept ``--jobs``.

Definition at line 185 of file test_contract_parity.py.

Here is the call graph for this function:

Variable Documentation

◆ _EXPECTED_SUBCOMMAND

dict tests_mcp.test_contract_parity._EXPECTED_SUBCOMMAND
protected
Initial value:
1= {
2 "oct_lint": ["lint"],
3 "oct_health": ["health"],
4 "oct_skeleton": ["export-skeleton"],
5 "oct_deps": ["deps"],
6 "oct_test": ["test"],
7 "oct_typecheck": ["typecheck"],
8 "oct_diag": ["diag", "validate-config"],
9 "oct_git_status": ["git", "status"],
10 "oct_git_check": ["git", "check"],
11 "oct_format": ["format"],
12 "oct_docs": ["docs"],
13 "oct_export_source": ["export-source"],
14 "oct_new": ["new"],
15 "oct_scaffold": ["scaffold"],
16 "oct_clean": ["clean"],
17 "oct_install_hooks": ["git", "hooks", "install"],
18 "oct_git_commit": ["git", "commit"],
19 "oct_git_hooks_install": ["git", "hooks", "install"],
20 "oct_git_init": ["git", "init"],
21 "oct_git_changelog": ["git", "changelog"],
22}

Definition at line 93 of file test_contract_parity.py.

◆ _MINIMAL_ARGS

dict tests_mcp.test_contract_parity._MINIMAL_ARGS
protected
Initial value:
1= {
2 "oct_lint": {},
3 "oct_health": {},
4 "oct_skeleton": {},
5 "oct_deps": {},
6 "oct_test": {},
7 "oct_typecheck": {},
8 "oct_diag": {},
9 "oct_git_status": {},
10 "oct_git_check": {},
11 "oct_format": {"apply": False, "confirm": False},
12 "oct_docs": {},
13 "oct_export_source": {},
14 "oct_new": {"path": "src/foo.py"},
15 "oct_scaffold": {"name": "example"},
16 "oct_clean": {},
17 "oct_install_hooks": {},
18 "oct_git_commit": {"message": "feat(core): add parity test"},
19 "oct_git_hooks_install": {},
20 "oct_git_init": {},
21 "oct_git_changelog": {},
22}

Definition at line 67 of file test_contract_parity.py.