Spaces:
Sleeping

TFA / test_agents.py
VAH6002's picture
Upload 61 files
1af9fb8 verified
Raw History Blame Contribute Delete
2.37 kB
"""Test TFA Agents with Google ADK and mock data."""
import asyncio
import os
# Set a dummy API key for testing (agents won't actually call Gemini with mock data)
# In production, set GOOGLE_API_KEY or use application default credentials
os.environ.setdefault("GOOGLE_API_KEY", "test-key-for-mock")
from tfa_agents.tools.sponge_mock import use_mock_client
from tfa_agents import TFARunner
async def test_tfa_pipeline():
"""Test the full TFA pipeline with mock data."""
print("\n" + "=" * 70)
print("TFA Agent Pipeline Test with Mock Data")
print("=" * 70)
# Configure mock client
use_mock_client("code_regression")
print("\nβœ“ Mock client configured for 'code_regression' scenario")
# Create runner
runner = TFARunner()
print("βœ“ TFA Runner initialized")
# Test parameters
invocation_id = "fe3e0b7f-7bb9-4524-8a79-3c62cf028243"
test_name = "//gmail/android/copycat:mark_multiple_emails_as_read"
print(f"\nAnalyzing failure:")
print(f" Invocation: {invocation_id}")
print(f" Test: {test_name}")
print("\nRunning TFA pipeline...")
print("-" * 70)
try:
result = await runner.analyze_failure_async(
invocation_id=invocation_id,
test_name=test_name,
)
print("\n" + "=" * 70)
print("ANALYSIS RESULT:")
print("=" * 70)
print(result)
except Exception as e:
print(f"\n❌ Error during analysis: {type(e).__name__}: {e}")
raise
def main():
"""Run the test."""
print("""
╔══════════════════════════════════════════════════════════════════════╗
β•‘ TFA (Test Failure Analysis) - Agent Pipeline Test β•‘
β•‘ Using Google ADK with Mock Sponge Data β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
""")
asyncio.run(test_tfa_pipeline())
print("\nβœ… Test completed!")
if __name__ == "__main__":
main()