Create a temporary agents directory with A2A agent configurations for testing.
()
| 812 | |
| 813 | @pytest.fixture |
| 814 | def temp_agents_dir_with_a2a(): |
| 815 | """Create a temporary agents directory with A2A agent configurations for testing.""" |
| 816 | with tempfile.TemporaryDirectory() as temp_dir: |
| 817 | # Create test agent directory |
| 818 | agent_dir = Path(temp_dir) / "test_a2a_agent" |
| 819 | agent_dir.mkdir() |
| 820 | |
| 821 | # Create agent.json file |
| 822 | agent_card = { |
| 823 | "name": "test_a2a_agent", |
| 824 | "description": "Test A2A agent", |
| 825 | "version": "1.0.0", |
| 826 | "author": "test", |
| 827 | "capabilities": ["text"], |
| 828 | } |
| 829 | |
| 830 | with open(agent_dir / "agent.json", "w") as f: |
| 831 | json.dump(agent_card, f) |
| 832 | |
| 833 | # Create a simple agent.py file |
| 834 | agent_py_content = """ |
| 835 | from google.adk.agents.base_agent import BaseAgent |
| 836 | |
| 837 | class TestA2AAgent(BaseAgent): |
| 838 | def __init__(self): |
| 839 | super().__init__(name="test_a2a_agent") |
| 840 | """ |
| 841 | |
| 842 | with open(agent_dir / "agent.py", "w") as f: |
| 843 | f.write(agent_py_content) |
| 844 | |
| 845 | yield temp_dir |
| 846 | |
| 847 | |
| 848 | @pytest.fixture |