Skip to content

test: add unit tests for MinimaxAPIClient#48

Open
mvanhorn wants to merge 1 commit intoMiniMax-AI:mainfrom
mvanhorn:test/api-client-unit-tests
Open

test: add unit tests for MinimaxAPIClient#48
mvanhorn wants to merge 1 commit intoMiniMax-AI:mainfrom
mvanhorn:test/api-client-unit-tests

Conversation

@mvanhorn
Copy link

Adds 8 unit tests for the MinimaxAPIClient class in client.py, covering all code paths with mocked HTTP via unittest.mock.

Test cases

  • Initialization (auth header, API source header, api_host storage)
  • Successful JSON POST request
  • Successful GET request
  • File upload POST (verifies Content-Type header is removed for multipart)
  • Auth error handling (status_code 1004 raises MinimaxAuthError)
  • Verification error handling (status_code 2038 raises MinimaxRequestError)
  • Generic API error handling (other status codes)
  • Network failure (requests.exceptions.RequestException)

Coverage impact

client.py coverage goes from 0% to 100%. Overall project coverage increases from ~21% to ~28%.

Files changed

  • tests/test_client.py - New file with 8 test cases
  • tests/conftest.py - Added api_client fixture

All existing tests continue to pass. No API calls are made - all HTTP is mocked.

This contribution was developed with AI assistance (Claude Code).

Adds 8 test cases covering all code paths in client.py:
initialization, successful JSON POST, successful GET, file upload
(multipart), auth error (1004), verification error (2038), generic
API error, and network failure. Coverage for client.py goes from 0%
to 100%.

Co-Authored-By: Claude Opus 4.6 <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.

1 participant