[Test Improver] test: add unit tests for RuntimeManager and runtime CLI commands (20%→92%, 49%→90%)#380
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Conversation
…→92%, 49%→90%) - Add 53 tests covering commands/runtime.py and runtime/manager.py - RuntimeManager: init, list_runtimes, is_runtime_available, get_available_runtime, setup_runtime (success/failure/exception/args), remove_runtime (copilot npm, binary file/dir, llm venv cleanup), get_embedded_script - CLI commands: setup/list/remove/status success and error paths, argument validation, Rich table fallback path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Test Improver — automated AI assistant
Goal and Rationale
runtime/manager.pyandcommands/runtime.pyhad almost no test coverage (49% and 20% respectively), yet they implement user-facing CLI commands for managing AI runtimes (install/list/remove/status). These are critical-path operations users run when setting up the tool. Low coverage here means regressions go undetected.Approach
Added
tests/unit/test_runtime_manager.pywith 53 focused unit tests covering:RuntimeManager(runtime/manager.py):list_runtimes: all-uninstalled, binary in APM dir, binary in system PATH, version detection (success + exception fallback)is_runtime_available: apm dir binary, directory (not file), system PATH fallback, unknown runtimeget_available_runtime: priority order, first-wins, none availablesetup_runtime: unsupported runtime, success/failure/exception, version and vanilla flag forwardingremove_runtime: unknown runtime, copilot npm (success/failure/exception), binary not installed, file removal, directory removal, LLM venv cleanupcommands/runtimeCLI (commands/runtime.py):setup: success, failure (exit 1), exception (exit 1),--version,--vanilla, invalid runtime namelist: exit 0, calls list_runtimes, exception (exit 1), Rich table fallback path showing runtime namesremove: success, failure (exit 1), exception (exit 1), invalid runtime namestatus: available runtime, no runtime available, exception (exit 1)Coverage Impact
src/apm_cli/commands/runtime.pysrc/apm_cli/runtime/manager.pyRemaining uncovered lines:
commands/runtime.py:171-182(fallback status display with no Rich panel),runtime/manager.py:53-56,85-88,98-101,119-120,137-138,172-174(PyInstaller bundle paths and Windows-specific script writing — these require platform-specific test environments).Trade-offs
.ps1scripts, PowerShell execution) not covered — would need platform-conditional tests or a Windows runnerReproducibility
uv sync --extra dev uv run pytest tests/unit/test_runtime_manager.py -v # Full suite uv run pytest tests/unit/ --no-header -qTest Status
✅ All 53 new tests pass
✅ Full suite: 2157 tests pass (up from 2104 before this PR)
✅ No regressions