a2a-source-edit: write tests/test_agent.py
This commit is contained in:
64
tests/test_agent.py
Normal file
64
tests/test_agent.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from a2a_pack import NoAuth
|
||||||
|
from a2a_pack.context import LocalRunContext
|
||||||
|
|
||||||
|
from agent import CustomerIntegrationEngineer
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_source_policy_rejects_code_editor_agent():
|
||||||
|
agent = CustomerIntegrationEngineer()
|
||||||
|
ctx = LocalRunContext(auth=NoAuth())
|
||||||
|
|
||||||
|
result = await agent.review_source_change_policy(
|
||||||
|
ctx,
|
||||||
|
mutated_source=False,
|
||||||
|
critical_defect_remaining=False,
|
||||||
|
used_code_editor_agent=True,
|
||||||
|
improvement_iterations=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["ok"] is False
|
||||||
|
failed = {check["name"] for check in result["checks"] if not check["ok"]}
|
||||||
|
assert "no_code_editor_agent" in failed
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_smoke_call_rejects_secret_like_result():
|
||||||
|
agent = CustomerIntegrationEngineer()
|
||||||
|
ctx = LocalRunContext(auth=NoAuth())
|
||||||
|
|
||||||
|
result = await agent.validate_smoke_call(
|
||||||
|
ctx,
|
||||||
|
{
|
||||||
|
"skill_name": "validate_live_card",
|
||||||
|
"input_args": {"bounded": True},
|
||||||
|
"result": {"ok": True, "api_key": "sk-testsecret1234567890"},
|
||||||
|
"status_code": 200,
|
||||||
|
"used_workspace_delegation": True,
|
||||||
|
"delegated_workspace_mode": "read_only",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["ok"] is False
|
||||||
|
failed = {check["name"] for check in result["checks"] if not check["ok"]}
|
||||||
|
assert "no_secrets_returned" in failed
|
||||||
|
assert "$.api_key" in result["secret_like_paths"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_final_report_passes_with_clean_validations():
|
||||||
|
agent = CustomerIntegrationEngineer()
|
||||||
|
ctx = LocalRunContext(auth=NoAuth())
|
||||||
|
|
||||||
|
result = await agent.final_release_report(
|
||||||
|
ctx,
|
||||||
|
validation_results=[{"checks": [{"name": "sample", "ok": True}]}],
|
||||||
|
reviewer_findings=[],
|
||||||
|
warnings_to_accept=[],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["ok"] is True
|
||||||
|
assert result["critical_findings"] == []
|
||||||
|
assert result["secrets_included"] is False
|
||||||
Reference in New Issue
Block a user