Skip to content

test(mamba-mcp-pg): add comprehensive test coverage#6

Merged
sequenzia merged 7 commits intomainfrom
phase5/pg-test-coverage
Feb 2, 2026
Merged

test(mamba-mcp-pg): add comprehensive test coverage#6
sequenzia merged 7 commits intomainfrom
phase5/pg-test-coverage

Conversation

@sequenzia
Copy link
Owner

Summary

New Test Files

File Tests Coverage
test_config.py 49 DatabaseSettings, ServerSettings, nested settings, env file state
test_errors.py 21 ErrorCode constants, ERROR_SUGGESTIONS completeness, create_tool_error wrapper, find_similar_names smoke tests
test_server.py 7 FastMCP instance, AppContext dataclass, app_lifespan lifecycle & error handling
test_models.py 128 All Pydantic I/O models with validation constraints, serialization, edge cases

Test plan

  • All 271 PG tests pass
  • All 778 HANA tests pass (no regressions)
  • All 51 core tests pass
  • Ruff lint clean

Add SAP HANA MCP server to README.md and CLAUDE.md with complete package
description, architecture details, and repository structure updates. Also
document mamba-mcp-fs utility modules (content.py, errors.py).
- Created internal/docs/codebase-analysis.md with comprehensive analysis of all 4 packages, including architecture overview, critical files, patterns, challenges, and recommendations
- Updated CLAUDE.md with Key Patterns to Follow (7 core patterns for server packages), Testing Conventions, and Known Inconsistencies to guide future development
- Updated README.md with Architecture section explaining the shared FastMCP + layered tool pattern and tech stack
…mba_mcp_hana

Resolve module name asymmetry where mamba-mcp-hana was the only package
that didn't follow the 1:1 naming convention (it used mamba_mcp_sap_hana
with an extra sap_ prefix). All other packages map directly:
mamba-mcp-pg → mamba_mcp_pg, mamba-mcp-fs → mamba_mcp_fs.

Changes:
- Rename src/mamba_mcp_sap_hana/ → src/mamba_mcp_hana/
- Update pyproject.toml entry point and build config
- Update all imports across source and test files
- Update CLAUDE.md, README.md, and codebase-analysis.md

BREAKING CHANGE: Module import path changed from mamba_mcp_sap_hana to mamba_mcp_hana
Create mamba-mcp-core to extract duplicated code from server packages:
- cli.py: validate_env_file, resolve_default_env_file, setup_logging
- config.py: module-level env file path state management
- errors.py: flat ToolError model + create_tool_error factory with
  server-specific suggestions_map parameter
- fuzzy.py: Levenshtein distance + find_similar_names with scaled
  threshold (max(2, min(len//2, 5))) — standardizes PG vs HANA approach
- transport.py: normalize_transport accepting both "http" and
  "streamable-http"

Includes 51 tests covering all modules. Addresses Challenges #3
(code duplication) and #6 (fuzzy matching inconsistency).
Replace duplicated code across all three server packages with shared
imports from mamba-mcp-core. This eliminates ~500 lines of copy-pasted
CLI utilities, config state management, error models, and fuzzy matching.

Changes per server:
- PG: core imports for CLI, config, errors, fuzzy; dict return preserved
- FS: core imports for CLI, config, transport; exception hierarchy kept
- HANA: core imports for CLI, config, errors, fuzzy, transport;
  removed redundant resolve_env_file(); ToolError return preserved;
  suggest_similar wrapper maps max_suggestions→max_results

Transport pattern updated to accept both "http" and "streamable-http"
in all servers, with normalize_transport() applied before mcp.run().

Test updates:
- HANA: removed TestLevenshteinDistance (now in core), removed
  TestResolveEnvFile (now in core), removed _levenshtein_distance import
- All existing tests pass (PG: 66, HANA: 778, Core: 51)
…S pattern

Change all 11 HANA tool functions from returning `str` (JSON) to
returning `OutputModel | dict[str, Any]` to match the PG/FS convention.

Tool changes (4 files, 11 tools):
- Return type annotations: `-> str` → `-> SpecificOutput | dict[str, Any]`
- Success paths: `result.model_dump_json()` → `result` (return model directly)
- Error paths: `error.model_dump_json()` → `error.model_dump()` (return dict)
- Added output model imports to each tool file

Test changes (4 files):
- Removed `json.loads(result)` calls throughout
- Success assertions: dict key access → model attribute access
- Error assertions: `json.loads(result)["code"]` → `result["code"]`
- Added `isinstance` checks for result types
- Removed unused `import json` statements

All 778 HANA tests pass.
…s, server, and models

Add 205 new tests across 4 test files to match HANA/FS test coverage:
- test_config.py: DatabaseSettings, ServerSettings, nested settings, env file state
- test_errors.py: ErrorCode constants, ERROR_SUGGESTIONS completeness, create_tool_error wrapper
- test_server.py: FastMCP instance, AppContext dataclass, app_lifespan lifecycle
- test_models.py: All Pydantic models with validation constraints, serialization, edge cases
Copilot AI review requested due to automatic review settings February 2, 2026 00:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive test coverage for the mamba-mcp-pg package and migrates all servers (PG, FS, HANA) to use the new mamba-mcp-core shared utilities package. The PR increases PG test count from 66 to 271 tests by adding test files for config, errors, server, and models.

Changes:

  • Introduces mamba-mcp-core package with shared CLI, config, error handling, fuzzy matching, and transport utilities
  • Adds 4 new test files to mamba-mcp-pg with 205 tests covering configuration, errors, server lifespan, and Pydantic models
  • Migrates PG, FS, and HANA servers to use core utilities, eliminating ~500 lines of duplicated code
  • Updates HANA package naming from mamba_mcp_sap_hana to mamba_mcp_hana for consistency

Reviewed changes

Copilot reviewed 65 out of 72 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/mamba-mcp-core/* New shared utilities package with CLI helpers, config state, error models, fuzzy matching, and transport normalization (51 new tests)
packages/mamba-mcp-pg/tests/* New test files for config (49), errors (21), server (7), models (128 claimed)
packages/mamba-mcp-pg/src/* Migration to use mamba-mcp-core for CLI, config, and error utilities
packages/mamba-mcp-hana/* Package rename and migration to mamba-mcp-core (778 test path updates)
packages/mamba-mcp-fs/* Migration to mamba-mcp-core for CLI and config utilities
pyproject.toml, uv.lock Workspace configuration updates for new core package

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,895 @@
"""Tests for Pydantic models: schema, relationships, and results."""
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test file is missing from the diff. According to the PR description, test_models.py should contain 128 tests covering "All Pydantic I/O models with validation constraints, serialization, edge cases". However, the file is not included in the provided diff, making it impossible to verify the test coverage claims.

Copilot uses AI. Check for mistakes.
async with app_lifespan(mock_server):
raise RuntimeError("something broke")

mock_dispose.assert_called_once_with(mock_engine)
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement is unreachable.

Copilot uses AI. Check for mistakes.
@sequenzia sequenzia merged commit 39ffeb3 into main Feb 2, 2026
6 checks passed
@sequenzia sequenzia deleted the phase5/pg-test-coverage branch February 2, 2026 01:47
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.

2 participants