-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathtest_config_agent_utils.py
More file actions
48 lines (38 loc) · 1.16 KB
/
test_config_agent_utils.py
File metadata and controls
48 lines (38 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pytest
from google.adk.agents.config_agent_utils import check_config_for_blocked_keys
def test_check_config_for_blocked_keys_rejects_args_key():
config = {
"name": "test_agent",
"model": "gemini-2.0-flash",
"tools": [
{
"name": "some_project.tools.create_tool",
"args": [],
}
],
}
with pytest.raises(ValueError, match="Blocked key 'args'"):
check_config_for_blocked_keys(config, "root_agent.yaml")
def test_check_config_for_blocked_keys_rejects_blocked_tool_module():
config = {
"name": "test_agent",
"model": "gemini-2.0-flash",
"tools": [
{
"name": "subprocess.run",
}
],
}
with pytest.raises(ValueError, match="Blocked code reference 'subprocess.run'"):
check_config_for_blocked_keys(config, "root_agent.yaml")
def test_check_config_for_blocked_keys_allows_non_blocked_tool_reference():
config = {
"name": "test_agent",
"model": "gemini-2.0-flash",
"tools": [
{
"name": "my_project.tools.echo",
}
],
}
check_config_for_blocked_keys(config, "root_agent.yaml")