-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_json_format.py
More file actions
53 lines (42 loc) · 1.46 KB
/
test_json_format.py
File metadata and controls
53 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""Test JSON response format"""
import json
from server import MCPServer
def test_json_response_format():
"""Verify JSON response format is correct"""
print("Testing JSON response format...")
server = MCPServer()
# Test 1: scan_project
result = server.handle_request("scan_project", {
"project_path": "/tmp/test-eu-ai-act"
})
print("\n1. scan_project response:")
print(json.dumps(result, indent=2))
assert "tool" in result
assert "results" in result
print("OK Valid JSON format")
# Test 2: check_compliance
result = server.handle_request("check_compliance", {
"project_path": "/tmp/test-eu-ai-act",
"risk_category": "limited"
})
print("\n2. check_compliance response:")
print(json.dumps(result, indent=2))
assert "tool" in result
assert "results" in result
print("OK Valid JSON format")
# Test 3: generate_report
result = server.handle_request("generate_report", {
"project_path": "/tmp/test-eu-ai-act",
"risk_category": "limited"
})
print("\n3. generate_report response:")
print(f"Keys: {list(result.keys())}")
print(f"Tool: {result.get('tool')}")
print(f"Results keys: {list(result.get('results', {}).keys())}")
assert "tool" in result
assert "results" in result
print("OK Valid JSON format")
print("\nOK All JSON formats are compliant")
if __name__ == "__main__":
test_json_response_format()