Skip to content

[Test Improver] test: add unit tests for MCPIntegrator (0% -> ~75%)#632

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/mcp-integrator-coverage-24166967264-5b2037248fd572ad
Draft

[Test Improver] test: add unit tests for MCPIntegrator (0% -> ~75%)#632
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/mcp-integrator-coverage-24166967264-5b2037248fd572ad

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver — automated AI assistant

Goal and Rationale

MCPIntegrator (src/apm_cli/integration/mcp_integrator.py, 1395 lines) is a large, high-risk orchestrator with zero dedicated tests. It owns MCP dependency resolution, deduplication, server-info building, drift detection, runtime detection, lockfile persistence, and stale cleanup across five runtimes (VS Code, Copilot, Codex, Cursor, OpenCode).

Bugs here could silently corrupt MCP configuration files across all runtimes. This PR adds focused unit tests for every pure-logic method.

Approach

Tests target the methods that can be verified without live runtimes or network:

Class Methods Covered
TestIsVscodeAvailable _is_vscode_available() — PATH + dir detection
TestDeduplicate deduplicate() — first-wins, dict/str/nameless entries, ordering
TestGetServerNames get_server_names() — dep objects, strings, mixed
TestGetServerConfigs get_server_configs() — serialization, plain-string fallback
TestAppendDrifted _append_drifted_to_install_list() — sorted append, dedup
TestDetectMcpConfigDrift _detect_mcp_config_drift() — changed/unchanged/new configs
TestDetectRuntimes _detect_runtimes() — word-boundary regex, multi-runtime
TestBuildSelfDefinedInfo _build_self_defined_info() — stdio, http/sse, env, args, headers, tools
TestApplyOverlay _apply_overlay() — transport, package filter, headers, args (list+dict), tools, warning
TestUpdateLockfile update_lockfile() — temp file writes, sorted servers, empty clear
TestRemoveStaleVscode remove_stale() — server removal, short-name matching, runtime targeting
TestRemoveStaleCopilot remove_stale() — copilot config cleanup
TestCollectTransitive collect_transitive() — missing/empty dir edge cases

Coverage Impact

Metric Before After
Test count 3,748 3,818
New tests 70
mcp_integrator.py coverage ~0% ~75%

Test Status

3818 passed in 14.33s

All 70 new tests pass. Full unit suite passes with no regressions.

Reproducibility

# Run new tests only
uv run pytest tests/unit/integration/test_mcp_integrator.py -v

# Run full unit suite
uv run pytest tests/unit tests/test_console.py -x -q

Generated by Daily Test Improver ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@b87234850bf9664d198f28a02df0f937d0447295

Cover pure-logic methods: deduplicate, get_server_names, get_server_configs,
_append_drifted_to_install_list, _detect_mcp_config_drift, _detect_runtimes,
_build_self_defined_info, _apply_overlay, update_lockfile, remove_stale
(vscode + copilot), and collect_transitive edge cases. 70 new tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant