/ mcp-scan / pytests / test_parse.py
test_parse.py
 1  from utils.parse import clean_content, parse_tool_invocations
 2  
 3  
 4  def test_parse_standard_finish():
 5      content = "<function=finish><parameter=content>done</parameter></function>"
 6      assert parse_tool_invocations(content) == {"toolName": "finish", "args": {"content": "done"}}
 7  
 8  
 9  def test_parse_short_finish():
10      content = "<finish>报告完成。</finish>"
11      assert parse_tool_invocations(content) == {
12          "toolName": "finish",
13          "args": {"content": "报告完成。"},
14      }
15  
16  
17  def test_clean_content_removes_finish_tag():
18      assert clean_content("<finish>报告完成。</finish>") == ""
19  
20  
21  def test_parse_normal_tool():
22      content = "<function=read_file><parameter=path>/tmp/a.py</parameter></function>"
23      assert parse_tool_invocations(content) == {
24          "toolName": "read_file",
25          "args": {"path": "/tmp/a.py"},
26      }