python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

test: add pytest coverage for SSE transport functions

Open passionateSandy2004 opened this issue 9 months ago • 0 comments

Added a new pytest function, test_remove_request_params, in tests/shared/test_sse.py to cover the previously untested remove_request_params utility in the SSE client module.

Motivation and Context

The remove_request_params function in src/mcp/client/sse.py was not directly tested, leaving potential edge cases unverified. By adding a focused unit test, we ensure that:

  • URLs with query parameters and fragments are correctly stripped down to their base form.
  • URLs without parameters remain unchanged.

This aligns the SSE client tests with the project’s coverage standards and closes gaps in our automated test suite.

How Has This Been Tested?

  • Ran pytest tests/shared/test_sse.py locally, confirming:
    • URLs like http://example.com/path?foo=bar#baz are normalized to http://example.com/path.
    • Clean URLs (e.g. https://mcp.dev/stream) pass through untouched.
  • Executed full test suite (pytest) to verify no regressions.

Breaking Changes

None. This update only adds tests and does not alter library behavior or public APIs.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation update

Checklist

  • [x] I have read the MCP Documentation
  • [x] My code follows the repository's style guidelines (pytest conventions)
  • [x] New and existing tests pass locally
  • [ ] I have added appropriate error handling
  • [x] I have added or updated documentation as needed (test coverage)

Additional context

This change brings the SSE client’s test coverage to 100% for its public utilities and contributes to overall library reliability.

passionateSandy2004 avatar Apr 22 '25 05:04 passionateSandy2004