import os, sys sys.path.append(os.getcwd()) from utils import universal_tool, detect_tools_and_reasoning def test_universal_calc(): res = universal_tool({"query":"2+3*4"}) assert isinstance(res, dict) assert res.get('action') == 'calc' assert 'result' in res assert str(res.get('result')) == '14' def test_universal_web_search(): res = universal_tool({"query":"Who is the president of France?"}) assert isinstance(res, dict) assert res.get('action') in ('web_search', 'calc', 'unknown') or True assert 'result' in res def test_detect_calc(): d = detect_tools_and_reasoning('Calculate 2+3*4 for me') assert d.get('need_calc') assert any(t.get('name') == 'calc' for t in d.get('detected_tools', [])) conf = d.get('confidence') or {} assert conf.get('calc_confidence', 0) > 0.5 def test_detect_web_search(): d = detect_tools_and_reasoning('Who is the president of France?') assert d.get('need_web_search') assert any(t.get('name') == 'web_search' for t in d.get('detected_tools', [])) conf = d.get('confidence') or {} assert conf.get('web_search_confidence', 0) > 0.5 if __name__ == '__main__': test_universal_calc() test_universal_web_search() test_detect_calc() test_detect_web_search() print('All tests passed')