Skip to content

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

@alfonsodg

Description

@alfonsodg

Problem

Test coverage is minimal. Only utils.py has tests. The two most critical modules — server.py (all tool functions) and client.py (API communication) — have zero test coverage.

Current test coverage

tests/
├── conftest.py      # 3 fixtures
└── test_utils.py    # 6 tests for utils.py only

Untested modules

Module Lines Tests Risk
server.py 800+ 0 HIGH — all user-facing tools
client.py 80 0 HIGH — API auth, error handling
const.py 30 0 LOW — just constants
exceptions.py 20 0 LOW — just class definitions
__main__.py 80 0 MEDIUM — config generation

Proposed solution

Priority 1: client.py tests

# tests/test_client.py
def test_client_auth_header():
    """Verify Authorization header is set correctly."""

def test_client_handles_api_error_codes():
    """Verify status_code != 0 raises appropriate exceptions."""

def test_client_handles_auth_error_1004():
    """Verify 1004 raises MinimaxAuthError."""

def test_client_handles_network_error():
    """Verify RequestException is wrapped in MinimaxRequestError."""

Priority 2: server.py tool tests (with mocked API)

# tests/test_tools.py
def test_text_to_audio_validates_empty_text():
    """Verify empty text raises MinimaxRequestError."""

def test_generate_video_validates_empty_prompt():
    """Verify empty prompt raises MinimaxRequestError."""

def test_text_to_image_validates_empty_prompt():
    """Verify empty prompt raises MinimaxRequestError."""

Use unittest.mock.patch to mock api_client calls.

Acceptance criteria

  • client.py has tests for auth, error handling, and request methods
  • Tool functions have tests for input validation and error paths
  • Coverage target: >60% for client.py, >40% for server.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions