Skip to content

Commit ae9ca47

Browse files
committed
test: fix AWS MCP integration test setup
1 parent 32bee81 commit ae9ca47

File tree

2 files changed

+3
-48
lines changed

2 files changed

+3
-48
lines changed

tests/integ/test_aws_mcp_server.py renamed to tests/integ/test_aws_mcp_server_happy_path.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Integration tests for AWS MCP Server at https://aws-mcp.us-east-1.api.aws/mcp."""
1+
"""Happy path integration tests for AWS MCP Server at https://aws-mcp.us-east-1.api.aws/mcp."""
22

33
import fastmcp
44
import logging
@@ -76,7 +76,7 @@ def verify_json_response(response: CallToolResult):
7676
("aws___search_documentation", {"search_phrase": "S3 bucket versioning"}),
7777
(
7878
"aws___recommend",
79-
{"url": "bad_url"},
79+
{"url": "https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html"},
8080
),
8181
(
8282
"aws___read_documentation",
@@ -86,7 +86,7 @@ def verify_json_response(response: CallToolResult):
8686
"aws___get_regional_availability",
8787
{"resource_type": "cfn", "region": "us-east-1"},
8888
),
89-
("aws___call_aws", {"cli_command": "aws s3 ls", "max_results": 50}),
89+
("aws___call_aws", {"cli_command": "aws s3 ls", "max_results": 10}),
9090
],
9191
ids=[
9292
"list_regions",

tests/integ/test_aws_mcp_server_negative.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,6 @@
99

1010
logger = logging.getLogger(__name__)
1111

12-
13-
@pytest.mark.asyncio(loop_scope="module")
14-
async def test_nonexistent_tool(aws_mcp_client: fastmcp.Client):
15-
"""Test that calling a nonexistent tool raises an exception.
16-
17-
This test will:
18-
- PASS when calling a nonexistent tool raises an exception
19-
- FAIL if the nonexistent tool somehow succeeds
20-
"""
21-
exception_raised = False
22-
exception_message = None
23-
24-
try:
25-
response = await aws_mcp_client.call_tool("aws___nonexistent_tool_12345", {})
26-
logger.info(f"Unexpected success, response: {response}")
27-
except Exception as e:
28-
exception_raised = True
29-
exception_message = str(e)
30-
logger.info(f"Exception raised as expected: {type(e).__name__}: {exception_message}")
31-
32-
# Assert that an exception was raised
33-
assert exception_raised, (
34-
f"Expected exception when calling nonexistent tool 'aws___nonexistent_tool_12345', "
35-
f"but call succeeded unexpectedly."
36-
)
37-
38-
# Verify the exception mentions the tool not being found
39-
error_message_lower = exception_message.lower()
40-
tool_error_patterns = [
41-
"not found",
42-
"unknown",
43-
"does not exist",
44-
"invalid tool",
45-
"tool",
46-
"unknown tool",
47-
]
48-
49-
assert any(pattern in error_message_lower for pattern in tool_error_patterns), (
50-
f"Exception was raised but doesn't appear to be about a missing tool. "
51-
f"Expected one of {tool_error_patterns}, but got: {exception_message[:200]}"
52-
)
53-
54-
logger.info(f"Test passed: Nonexistent tool correctly raised exception")
55-
56-
5712
@pytest.mark.asyncio(loop_scope="module")
5813
async def test_expired_credentials():
5914
"""Test that expired credentials are properly rejected.

0 commit comments

Comments
 (0)