Verify that is_single_agent_directory only identifies directories with agent.py or root_agent.yaml.
(tmp_path)
| 2982 | |
| 2983 | |
| 2984 | def test_is_single_agent_directory(tmp_path): |
| 2985 | """Verify that is_single_agent_directory only identifies directories with agent.py or root_agent.yaml.""" |
| 2986 | from google.adk.cli.utils.agent_loader import is_single_agent_directory |
| 2987 | |
| 2988 | # Directory with agent.py (should be identified as agent) |
| 2989 | agent_py_dir = tmp_path / "agent_py_dir" |
| 2990 | agent_py_dir.mkdir() |
| 2991 | (agent_py_dir / "agent.py").write_text("root_agent = 'dummy'") |
| 2992 | assert is_single_agent_directory(str(agent_py_dir)) is True |
| 2993 | |
| 2994 | # Directory with root_agent.yaml (should be identified as agent) |
| 2995 | yaml_dir = tmp_path / "yaml_dir" |
| 2996 | yaml_dir.mkdir() |
| 2997 | (yaml_dir / "root_agent.yaml").write_text("root_agent: dummy") |
| 2998 | assert is_single_agent_directory(str(yaml_dir)) is True |
| 2999 | |
| 3000 | # Normal directory or standard package with __init__.py only (should NOT be identified as agent) |
| 3001 | normal_pkg = tmp_path / "normal_pkg" |
| 3002 | normal_pkg.mkdir() |
| 3003 | (normal_pkg / "__init__.py").write_text( |
| 3004 | "from .app import App\nimport something" |
| 3005 | ) |
| 3006 | assert is_single_agent_directory(str(normal_pkg)) is False |
| 3007 | |
| 3008 | |
| 3009 | def test_agent_loader_single_agent_mode(tmp_path): |
nothing calls this directly
no test coverage detected