forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_issue_1363_question_intake.py
More file actions
72 lines (59 loc) 路 2.2 KB
/
Copy pathtest_issue_1363_question_intake.py
File metadata and controls
72 lines (59 loc) 路 2.2 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Contract test for issue #1363's ``question`` intake kind.
Run against the deployed MCP endpoint with::
MISAKANET_MCP_URL=https://misakanet.org/mcp pytest -q \
tests/test_issue_1363_question_intake.py
The test is opt-in so normal CI never creates a real intake issue.
"""
import json
import os
import urllib.request
import pytest
MCP_URL = os.getenv("MISAKANET_MCP_URL")
pytestmark = pytest.mark.skipif(not MCP_URL, reason="set MISAKANET_MCP_URL for live MCP contract test")
def call_tool(name, arguments, request_id=1):
assert MCP_URL is not None
payload = {
"jsonrpc": "2.0",
"id": request_id,
"method": "tools/call",
"params": {"name": name, "arguments": arguments},
}
request = urllib.request.Request(
MCP_URL,
data=json.dumps(payload).encode(),
headers={
"Content-Type": "application/json",
"User-Agent": "MisakaNet-issue-1363-contract-test/1.0",
},
method="POST",
)
with urllib.request.urlopen(request, timeout=30) as response:
assert response.status == 200
return json.loads(response.read())
def test_question_kind_is_accepted_and_structured():
"""A question is accepted and returned as a created, structured intake."""
result = call_tool(
"misakanet_submit_intake",
{
"kind": "question",
"problem": "How do I configure MCP server authentication for production?",
"source": "issue-1363-contract-test",
},
)
assert "error" not in result, result
text = result["result"]["content"][0]["text"]
response = json.loads(text)
assert response["submitted"] is True
assert response["intake_id"]
assert "github issue" in response["receipt"].lower()
def test_search_response_is_valid_json():
"""The deployed search tool returns a parseable result envelope."""
result = call_tool(
"misakanet_search",
{"query": "quantum computing error correction"},
request_id=2,
)
text = result["result"]["content"][0]["text"]
response = json.loads(text)
assert isinstance(response["results"], list)
assert response["query"] == "quantum computing error correction"