Skip to content

Commit bca70e4

Browse files
committed
adapt tests to new constructor
1 parent 2afbc32 commit bca70e4

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

tests/test_yaml_parser.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_yaml_parser_basic_functionality(self):
1818
"""Test basic YAML parsing functionality."""
1919
# create a temporary directory with test yaml files
2020
with tempfile.TemporaryDirectory() as temp_dir:
21+
temp_path = Path(temp_dir)
2122
test_yaml_content = {
2223
'seclab-taskflow-agent': {
2324
'type': 'taskflow',
@@ -33,18 +34,19 @@ def test_yaml_parser_basic_functionality(self):
3334
]
3435
}
3536

36-
test_file = Path(temp_dir) / 'test_taskflow.yaml'
37+
test_file = temp_path / 'test_taskflow.yaml'
3738
with open(test_file, 'w') as f:
3839
yaml.dump(test_yaml_content, f)
3940

40-
# Test parsing
41-
parser = YamlParser(temp_dir)
42-
result = parser.get_yaml_dict(recurse=False)
41+
parser = YamlParser(temp_path)
42+
# get all yaml files in the directory
43+
yaml_files = temp_path.glob('*.yaml')
44+
result = parser.get_yaml_dict(yaml_files)
4345

44-
assert 'test_taskflow' in result
45-
assert result['test_taskflow']['seclab-taskflow-agent']['type'] == 'taskflow'
46-
assert len(result['test_taskflow']['taskflow']) == 1
47-
assert result['test_taskflow']['taskflow'][0]['task']['agents'] == ['assistant']
46+
assert 'test_taskflow.yaml' in result
47+
assert result['test_taskflow.yaml']['seclab-taskflow-agent']['type'] == 'taskflow'
48+
assert len(result['test_taskflow.yaml']['taskflow']) == 1
49+
assert result['test_taskflow.yaml']['taskflow'][0]['task']['agents'] == ['assistant']
4850

4951

5052
class TestRealTaskflowFiles:
@@ -53,29 +55,36 @@ class TestRealTaskflowFiles:
5355
def test_parse_example_taskflows(self):
5456
"""Test parsing the actual example taskflow files."""
5557
# this test uses the actual taskflows in the project
56-
parser = YamlParser('taskflows/examples')
57-
result = parser.get_yaml_dict()
58+
examples_path = Path('taskflows/examples').absolute()
59+
parser = YamlParser(examples_path)
60+
61+
# Get all YAML files in the examples directory
62+
yaml_files = examples_path.glob('*.yaml')
63+
result = parser.get_yaml_dict(yaml_files)
5864

5965
# should contain example files
6066
assert len(result) > 0
6167

6268
# check that example.yaml is parsed correctly
63-
example_task_flow = result['example']
69+
example_task_flow = result['example.yaml']
6470
assert 'taskflow' in example_task_flow
6571
assert isinstance(example_task_flow['taskflow'], list)
66-
assert len(example_task_flow['taskflow']) == 4 # 4 tasks in taskflow
72+
assert len(example_task_flow['taskflow']) == 4 # 4 tasks in taskflow
6773
assert example_task_flow['taskflow'][0]['task']['max_steps'] == 20
6874

6975
def test_parse_all_taskflows(self):
7076
"""Test parsing all example taskflow files in the project."""
71-
parser = YamlParser('taskflows')
72-
result = parser.get_yaml_dict(recurse=True, dir_namespace=True)
77+
taskflows_path = Path('taskflows').absolute()
78+
parser = YamlParser(taskflows_path)
79+
80+
yaml_files = taskflows_path.rglob('*.yaml')
81+
result = parser.get_yaml_dict(yaml_files)
7382

7483
# should contain all taskflow files (including subdirs)
7584
assert len(result) == 13
7685

77-
# check access for files with namespacing
78-
example_files = [key for key in result.keys() if key.startswith('examples/')]
86+
# check access for files with directory structure in names
87+
example_files = [key for key in result.keys() if 'examples/' in key]
7988
assert len(example_files) > 0
8089

8190

0 commit comments

Comments
 (0)