🧪 Testing Summary
PR #3202's deep review test-coverage analyzer flagged six paths in mcpgateway/services/grpc_service.py and mcpgateway/services/tool_service.py that are unit-tested at the helper level but not exercised end-to-end. Bundling them into a single follow-up issue rather than scattering 6 micro-issues.
📋 Test gaps
Production code in scope:
mcpgateway/services/grpc_service.py::invoke_method()
mcpgateway/services/grpc_service.py::delete_service()
mcpgateway/services/grpc_service.py::_sync_tools_from_reflection()
mcpgateway/services/tool_service.py::invoke_tool() (gRPC dispatch branch)
Specific paths needing coverage:
-
delete_service chunked deletion (>500 tools) — the range(0, len(tool_ids), 500) loop is correct by inspection but never exercised by a test. Fixture: 1200 stale tools, assert 9 execute calls (3 chunks × 3 deletes).
-
invoke_method gRPC metadata propagation — service.grpc_metadata is forwarded to GrpcEndpoint(metadata=...) but no test verifies the kwarg actually arrives. Spy on the GrpcEndpoint constructor.
-
invoke_method exception wrapping — when endpoint.invoke() raises an arbitrary RuntimeError, the catch site re-raises as GrpcServiceError("Method invocation failed: …"). Verify the wrap and the from e chain.
-
invoke_method finally-block close — when endpoint.invoke() raises, endpoint.close() must still be called. Today only happy-path tests exercise the close.
-
_sync_tools_from_reflection schema-only-changed update — existing test changes url; need a test that ONLY changes input_schema (e.g., a method's input proto type changes between reflections) and verifies the tool is updated and the tools_updated counter increments.
-
_sync_tools_from_reflection custom-description preserved counter — existing test verifies the description is preserved; need to assert tools_updated is NOT incremented in that branch (the changed=False path).
📋 Acceptance Criteria
Each gap above lands as a named test in tests/unit/mcpgateway/services/test_grpc_service.py and tests/unit/mcpgateway/services/test_tool_service.py. All 6 tests pass. No production code changes.
🔗 Context
🧪 Testing Summary
PR #3202's deep review test-coverage analyzer flagged six paths in
mcpgateway/services/grpc_service.pyandmcpgateway/services/tool_service.pythat are unit-tested at the helper level but not exercised end-to-end. Bundling them into a single follow-up issue rather than scattering 6 micro-issues.📋 Test gaps
Production code in scope:
mcpgateway/services/grpc_service.py::invoke_method()mcpgateway/services/grpc_service.py::delete_service()mcpgateway/services/grpc_service.py::_sync_tools_from_reflection()mcpgateway/services/tool_service.py::invoke_tool()(gRPC dispatch branch)Specific paths needing coverage:
delete_servicechunked deletion (>500 tools) — therange(0, len(tool_ids), 500)loop is correct by inspection but never exercised by a test. Fixture: 1200 stale tools, assert 9 execute calls (3 chunks × 3 deletes).invoke_methodgRPC metadata propagation —service.grpc_metadatais forwarded toGrpcEndpoint(metadata=...)but no test verifies the kwarg actually arrives. Spy on theGrpcEndpointconstructor.invoke_methodexception wrapping — whenendpoint.invoke()raises an arbitraryRuntimeError, the catch site re-raises asGrpcServiceError("Method invocation failed: …"). Verify the wrap and thefrom echain.invoke_methodfinally-block close — whenendpoint.invoke()raises,endpoint.close()must still be called. Today only happy-path tests exercise the close._sync_tools_from_reflectionschema-only-changed update — existing test changesurl; need a test that ONLY changesinput_schema(e.g., a method's input proto type changes between reflections) and verifies the tool is updated and thetools_updatedcounter increments._sync_tools_from_reflectioncustom-description preserved counter — existing test verifies the description is preserved; need to asserttools_updatedis NOT incremented in that branch (thechanged=Falsepath).📋 Acceptance Criteria
Each gap above lands as a named test in
tests/unit/mcpgateway/services/test_grpc_service.pyandtests/unit/mcpgateway/services/test_tool_service.py. All 6 tests pass. No production code changes.🔗 Context
TestSecurityHardening,TestVisibilityPropagation,TestInvokeMethodGuards); these 6 fill remaining gaps the PR review flagged.