Skip to content

Commit 3486590

Browse files
committed
test: added basic extract json tests for terminal tool
1 parent 903bf26 commit 3486590

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_tools_subagent.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
3+
from gptme.tools.subagent import _extract_json
4+
5+
6+
def test_extract_json_block():
7+
s = """
8+
Here is a result:
9+
```json
10+
{ "status": "ok" }
11+
```
12+
"""
13+
assert _extract_json(s) == '{ "status": "ok" }'
14+
15+
16+
def test_extract_json_raw():
17+
s = """
18+
{
19+
"result": "The 49th Fibonacci number is 7778742049.",
20+
"status": "success"
21+
}
22+
"""
23+
assert json.loads(_extract_json(s)) == json.loads(s)
24+
25+
26+
def test_extract_json_empty():
27+
s = ""
28+
assert _extract_json(s) == ""

0 commit comments

Comments
 (0)