test: strengthen assertions across 3 more test files (batch 2)
test_run_agent.py (2 weak → 0, +13 assertions): - Session ID validated against actual YYYYMMDD_HHMMSS_hex format - API failure verifies error message propagation - Invalid JSON args verifies empty dict fallback + message structure - Context compression verifies final_response + completed flag - Invalid tool name retry verifies api_calls count - Invalid response verifies completed/failed/error structure test_model_tools.py (3 weak → 0): - Unknown tool error includes tool name in message - Exception returns dict with 'error' key + non-empty message - get_all_tool_names verifies both web_search AND terminal present test_approval.py (1 weak → 0, assert ratio 1.1 → 2.2): - Dangerous commands verify description content (delete, shell, drop, etc.) - Safe commands explicitly assert key AND desc are None - Pre/post condition checks for state management
This commit is contained in:
parent
a44e041acf
commit
5c867fd79f
3 changed files with 157 additions and 50 deletions
|
|
@ -27,12 +27,16 @@ class TestHandleFunctionCall:
|
|||
def test_unknown_tool_returns_error(self):
|
||||
result = json.loads(handle_function_call("totally_fake_tool_xyz", {}))
|
||||
assert "error" in result
|
||||
assert "totally_fake_tool_xyz" in result["error"]
|
||||
|
||||
def test_exception_returns_json_error(self):
|
||||
# Even if something goes wrong, should return valid JSON
|
||||
result = handle_function_call("web_search", None) # None args may cause issues
|
||||
parsed = json.loads(result)
|
||||
assert isinstance(parsed, dict)
|
||||
assert "error" in parsed
|
||||
assert len(parsed["error"]) > 0
|
||||
assert "error" in parsed["error"].lower() or "failed" in parsed["error"].lower()
|
||||
|
||||
|
||||
# =========================================================================
|
||||
|
|
@ -82,7 +86,8 @@ class TestBackwardCompat:
|
|||
assert isinstance(names, list)
|
||||
assert len(names) > 0
|
||||
# Should contain well-known tools
|
||||
assert "web_search" in names or "terminal" in names
|
||||
assert "web_search" in names
|
||||
assert "terminal" in names
|
||||
|
||||
def test_get_toolset_for_tool(self):
|
||||
result = get_toolset_for_tool("web_search")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue