Skip to content

test: expand coverage to server.py and __main__.py (#72)#87

Open
TumCucTom wants to merge 1 commit into
MiniMax-AI:mainfrom
TumCucTom:feat/mcp-72-test-coverage
Open

test: expand coverage to server.py and __main__.py (#72)#87
TumCucTom wants to merge 1 commit into
MiniMax-AI:mainfrom
TumCucTom:feat/mcp-72-test-coverage

Conversation

@TumCucTom
Copy link
Copy Markdown

Summary

  • New tests/test_server.py with mocked-end-to-end tests for the major @mcp.tool() functions: text_to_audio, text_to_image, music_generation, play_audio, generate_video, voice_clone. Covers input-validation fast-fail paths, filesystem-path construction, and the success path with a mocked api_client.
  • New tests/test_main.py with import-time and entry-point smoke tests for __main__.py.
  • No production code changed. Tests use unittest.mock to avoid real API / audio calls.

Why

Issue #72: the test suite only covered utils.py. server.py (~746 lines, the entire MCP tool surface) and __main__.py were at 0% coverage, so any regression in those files would go unnoticed.

Coverage

Before: server.py 0% (287/287 stmts missed), __main__.py 0% (51/51 stmts missed).
After: server.py 92% (22 stmts missed), __main__.py 100%. Total project coverage 88%.

The 22 missed lines in server.py are mostly defensive exception handlers for IOError/RequestException paths that don't naturally fire when the api_client is mocked.

Test plan

  • pytest tests/ -v — all 74 tests pass
  • pytest --cov=minimax_mcp --cov-report=term-missing — shows the coverage improvement
  • Mutation-test sanity check: temporarily breaking the text_to_audio "Text is required" check makes 2 tests fail with DID NOT RAISE, confirming the tests are not vacuous. Same for music_generation's prompt/lyrics checks.

Fixes #72.

Generated with Claude Code

The existing tests/ directory only covered utils.py. server.py (~746
lines, all the @mcp.tool() functions) and __main__.py (~100 lines,
the CLI entry) were at 0% coverage, meaning any regression in the
public MCP tool surface or the CLI launch path would go unnoticed.

Add:
- tests/test_server.py with mocked-end-to-end tests for the major
  tool functions (text_to_audio, text_to_image, music_generation,
  play_audio, generate_video, voice_clone) plus input-validation
  and filesystem-path-construction tests.
- tests/test_main.py with import-time and entry-point smoke tests
  for __main__.py.

All tests use unittest.mock to avoid network/audio calls. Coverage
of server.py climbs from 0% to 92%, __main__.py from 0% to 100%.
No production code changed; test files only.

Fixes MiniMax-AI#72.

Co-authored-by: Zippy AI <tomkinsbale@icloud.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: expand test coverage — only utils tested, server and client have zero tests

1 participant