Skip to content

Commit 3cabf96

Browse files
committed
updated / fadded tests
1 parent a6fda24 commit 3cabf96

File tree

1 file changed

+131
-4
lines changed

1 file changed

+131
-4
lines changed

tests/agents/tide/test_utils_parse_steps_markdown.py

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def generate_steps_md(n):
1212
**context_identifiers**:
1313
- module.{i}
1414
- path/to/file_{i}.py
15+
**modify_identifiers**:
16+
- output/result_{i}.py
17+
- config/settings_{i}.json
1518
---""")
1619
steps_md.append("*** End Steps")
1720
return "\n".join(steps_md)
@@ -25,23 +28,36 @@ def test_parse_multiple_steps():
2528
**context_identifiers**:
2629
- db.init_schema
2730
- config/db.yaml
31+
**modify_identifiers**:
32+
- database/schema.sql
33+
- config/database.ini
2834
---
2935
1. **Load seed data**
3036
**instructions**: Populate tables with initial records from seed_data.json
3137
**context_identifiers**:
3238
- db.load_seed
3339
- data/seed_data.json
40+
**modify_identifiers**:
41+
- database/populated.db
42+
- logs/seed_import.log
3443
---
3544
*** End Steps
3645
"""
3746
steps = parse_steps_markdown(md)
47+
3848
assert len(steps) == 2
49+
50+
# Test step 0
3951
assert steps[0]["step"] == 0
4052
assert steps[0]["description"] == "Initialize database"
4153
assert "SQLite database" in steps[0]["instructions"]
4254
assert steps[0]["context_identifiers"] == ["db.init_schema", "config/db.yaml"]
55+
assert steps[0]["modify_identifiers"] == ["database/schema.sql", "config/database.ini"]
56+
57+
# Test step 1
4358
assert steps[1]["step"] == 1
4459
assert steps[1]["context_identifiers"][1] == "data/seed_data.json"
60+
assert steps[1]["modify_identifiers"] == ["database/populated.db", "logs/seed_import.log"]
4561

4662
def test_single_step():
4763
md = """
@@ -50,6 +66,8 @@ def test_single_step():
5066
**instructions**: Perform all required tasks in a single step.
5167
**context_identifiers**:
5268
- utils.main_handler
69+
**modify_identifiers**:
70+
- output/final_result.txt
5371
---
5472
*** End Steps
5573
"""
@@ -59,36 +77,72 @@ def test_single_step():
5977
assert steps[0]["description"] == "Do everything"
6078
assert "single step" in steps[0]["instructions"]
6179
assert steps[0]["context_identifiers"] == ["utils.main_handler"]
80+
assert steps[0]["modify_identifiers"] == ["output/final_result.txt"]
6281

63-
def test_missing_context_identifiers():
82+
def test_empty_identifiers():
6483
md = """
6584
*** Begin Steps
66-
0. **No context**
85+
0. **No identifiers**
6786
**instructions**: Just explain something here
6887
**context_identifiers**:
88+
**modify_identifiers**:
6989
---
7090
*** End Steps
7191
"""
7292
steps = parse_steps_markdown(md)
7393
assert len(steps) == 1
7494
assert steps[0]["context_identifiers"] == []
95+
assert steps[0]["modify_identifiers"] == []
96+
97+
def test_partial_empty_identifiers():
98+
md = """
99+
*** Begin Steps
100+
0. **Only context**
101+
**instructions**: Has context but no modify identifiers
102+
**context_identifiers**:
103+
- some.module
104+
- some/file.py
105+
**modify_identifiers**:
106+
---
107+
1. **Only modify**
108+
**instructions**: Has modify but no context identifiers
109+
**context_identifiers**:
110+
**modify_identifiers**:
111+
- output/result.json
112+
- logs/activity.log
113+
---
114+
*** End Steps
115+
"""
116+
steps = parse_steps_markdown(md)
117+
assert len(steps) == 2
118+
119+
# Step with only context
120+
assert steps[0]["context_identifiers"] == ["some.module", "some/file.py"]
121+
assert steps[0]["modify_identifiers"] == []
122+
123+
# Step with only modify
124+
assert steps[1]["context_identifiers"] == []
125+
assert steps[1]["modify_identifiers"] == ["output/result.json", "logs/activity.log"]
75126

76127
def test_malformed_but_parsable_step():
77128
md = """
78129
*** Begin Steps
79130
0. **Incomplete step**
80-
**instructions**: This has no context identifiers
131+
**instructions**: This has empty identifier lines
81132
**context_identifiers**:
82133
-
134+
**modify_identifiers**:
135+
-
83136
---
84137
*** End Steps
85138
"""
86139
steps = parse_steps_markdown(md)
87140
assert len(steps) == 1
88141
assert steps[0]["description"] == "Incomplete step"
89142
assert steps[0]["context_identifiers"] == []
143+
assert steps[0]["modify_identifiers"] == []
90144

91-
def test_multiple_hyphen_indented_contexts():
145+
def test_multiple_hyphen_indented_identifiers():
92146
md = """
93147
*** Begin Steps
94148
0. **Handle multi-line**
@@ -97,12 +151,40 @@ def test_multiple_hyphen_indented_contexts():
97151
- module.first
98152
- module.second
99153
- module.third
154+
**modify_identifiers**:
155+
- output/first.py
156+
- output/second.py
157+
- output/third.py
158+
- logs/process.log
100159
---
101160
*** End Steps
102161
"""
103162
steps = parse_steps_markdown(md)
104163
assert len(steps) == 1
105164
assert steps[0]["context_identifiers"] == ["module.first", "module.second", "module.third"]
165+
assert steps[0]["modify_identifiers"] == ["output/first.py", "output/second.py", "output/third.py", "logs/process.log"]
166+
167+
def test_mixed_whitespace_handling():
168+
md = """
169+
*** Begin Steps
170+
0. **Whitespace test**
171+
**instructions**: Test various whitespace scenarios
172+
**context_identifiers**:
173+
- module.with.spaces
174+
- indented.module
175+
- normal.module
176+
**modify_identifiers**:
177+
- output/spaced.file
178+
- output/indented.file
179+
- output/normal.file
180+
---
181+
*** End Steps
182+
"""
183+
steps = parse_steps_markdown(md)
184+
assert len(steps) == 1
185+
# Should strip whitespace from identifier names
186+
assert steps[0]["context_identifiers"] == ["module.with.spaces", "indented.module", "normal.module"]
187+
assert steps[0]["modify_identifiers"] == ["output/spaced.file", "output/indented.file", "output/normal.file"]
106188

107189
@pytest.mark.parametrize("count", [5, 10, 50])
108190
def test_large_number_of_steps(count):
@@ -116,3 +198,48 @@ def test_large_number_of_steps(count):
116198
assert step["description"] == f"Step {i} description"
117199
assert f"task {i}" in step["instructions"]
118200
assert step["context_identifiers"] == [f"module.{i}", f"path/to/file_{i}.py"]
201+
assert step["modify_identifiers"] == [f"output/result_{i}.py", f"config/settings_{i}.json"]
202+
203+
def test_complex_real_world_example():
204+
"""Test with a more realistic example that might be seen in practice."""
205+
md = """
206+
*** Begin Steps
207+
0. **Setup authentication system**
208+
**instructions**: Create user authentication with JWT tokens and bcrypt password hashing
209+
**context_identifiers**:
210+
- auth.models.User
211+
- auth.utils.jwt_helper
212+
- config/security.yaml
213+
- requirements.txt
214+
**modify_identifiers**:
215+
- auth/models.py
216+
- auth/views.py
217+
- auth/serializers.py
218+
- config/settings.py
219+
---
220+
1. **Implement API endpoints**
221+
**instructions**: Create REST API endpoints for user registration, login, and profile management
222+
**context_identifiers**:
223+
- auth.models.User
224+
- api.base_views
225+
- docs/api_spec.md
226+
**modify_identifiers**:
227+
- api/auth_views.py
228+
- api/urls.py
229+
- tests/test_auth_api.py
230+
---
231+
*** End Steps
232+
"""
233+
steps = parse_steps_markdown(md)
234+
assert len(steps) == 2
235+
236+
# Verify complex step structure
237+
assert steps[0]["description"] == "Setup authentication system"
238+
assert "JWT tokens" in steps[0]["instructions"]
239+
assert len(steps[0]["context_identifiers"]) == 4
240+
assert len(steps[0]["modify_identifiers"]) == 4
241+
242+
assert steps[1]["description"] == "Implement API endpoints"
243+
assert "REST API" in steps[1]["instructions"]
244+
assert len(steps[1]["context_identifiers"]) == 3
245+
assert len(steps[1]["modify_identifiers"]) == 3

0 commit comments

Comments
 (0)