-
Notifications
You must be signed in to change notification settings - Fork 215
Expand file tree
/
Copy pathtest_agents_config.py
More file actions
83 lines (72 loc) · 2.33 KB
/
test_agents_config.py
File metadata and controls
83 lines (72 loc) · 2.33 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import os
import shutil
import unittest
from pathlib import Path
from agentstack import conf
from agentstack.agents import AgentConfig, AGENTS_FILENAME
BASE_PATH = Path(__file__).parent
class AgentConfigTest(unittest.TestCase):
def setUp(self):
self.project_dir = BASE_PATH / 'tmp/agent_config'
conf.set_path(self.project_dir)
os.makedirs(self.project_dir / 'src/config')
def tearDown(self):
shutil.rmtree(self.project_dir)
def test_empty_file(self):
config = AgentConfig("agent_name")
assert config.name == "agent_name"
assert config.role == ""
assert config.goal == ""
assert config.backstory == ""
assert config.llm == ""
def test_read_minimal_yaml(self):
shutil.copy(BASE_PATH / "fixtures/agents_min.yaml", self.project_dir / AGENTS_FILENAME)
config = AgentConfig("agent_name")
assert config.name == "agent_name"
assert config.role == ""
assert config.goal == ""
assert config.backstory == ""
assert config.llm == ""
def test_read_maximal_yaml(self):
shutil.copy(BASE_PATH / "fixtures/agents_max.yaml", self.project_dir / AGENTS_FILENAME)
config = AgentConfig("agent_name")
assert config.name == "agent_name"
assert config.role == "role"
assert config.goal == "this is a goal"
assert config.backstory == "backstory"
assert config.llm == "provider/model"
def test_write_yaml(self):
with AgentConfig("agent_name") as config:
config.role = "role"
config.goal = "this is a goal"
config.backstory = "backstory"
config.llm = "provider/model"
yaml_src = open(self.project_dir / AGENTS_FILENAME).read()
assert (
yaml_src
== """agent_name:
role: >-
role
goal: >-
this is a goal
backstory: >-
backstory
llm: provider/model
"""
)
def test_write_none_values(self):
with AgentConfig("agent_name") as config:
config.role = None
config.goal = None
config.backstory = None
config.llm = None
yaml_src = open(self.project_dir / AGENTS_FILENAME).read()
assert (
yaml_src
== """agent_name:
role: >
goal: >
backstory: >
llm:
"""
)