Skip to content

Commit 556fc48

Browse files
committed
fix: Fix remaining CLI integration and lifecycle tests
- Fixed CLI tests to use empty guardrails directory to avoid lifecycle validation rules - Changed --enable-streaming to correct --streaming flag - Fixed lifecycle.py validate_dag to return proper ValidationError objects instead of empty lists - Added --guardrails-dir option to all failing CLI tests to point to empty test directory All 6 remaining test failures should now pass.
1 parent 9dfca32 commit 556fc48

File tree

2 files changed

+71
-9
lines changed

2 files changed

+71
-9
lines changed

tests/test_cli_integration.py

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ def sample_project(tmp_path):
3939
</grammar>"""
4040
(schemas / "lifecycle.rng").write_text(schema_content)
4141

42-
# Create guardrails directory (can be empty)
42+
# Create guardrails directory (empty - no guardrail checks)
4343
guardrails = project / "lib" / "guardrails"
4444
guardrails.mkdir(parents=True)
45+
# Add a dummy file to prevent directory issues
46+
(guardrails / ".gitkeep").write_text("")
4547

46-
# Create sample XML files
48+
# Create sample XML files that match the simple schema
4749
xml_content = """<?xml version="1.0" encoding="UTF-8"?>
4850
<document>
4951
<title>Sample Document</title>
@@ -79,7 +81,14 @@ def test_validate_success(self, runner, sample_project):
7981
"""Test validating a valid project succeeds."""
8082
result = runner.invoke(
8183
main,
82-
["--telemetry", "none", "validate", str(sample_project)],
84+
[
85+
"--telemetry",
86+
"none",
87+
"validate",
88+
str(sample_project),
89+
"--guardrails-dir",
90+
str(sample_project / "lib" / "guardrails"),
91+
],
8392
)
8493

8594
# Should exit with code 0 for success
@@ -94,7 +103,9 @@ def test_validate_with_streaming(self, runner, sample_project):
94103
"none",
95104
"validate",
96105
str(sample_project),
97-
"--enable-streaming",
106+
"--streaming",
107+
"--guardrails-dir",
108+
str(sample_project / "lib" / "guardrails"),
98109
],
99110
)
100111

@@ -445,7 +456,15 @@ def test_telemetry_file(self, runner, sample_project, tmp_path):
445456
def test_telemetry_none(self, runner, sample_project):
446457
"""Test validation with no telemetry."""
447458
result = runner.invoke(
448-
main, ["--telemetry", "none", "validate", str(sample_project)]
459+
main,
460+
[
461+
"--telemetry",
462+
"none",
463+
"validate",
464+
str(sample_project),
465+
"--guardrails-dir",
466+
str(sample_project / "lib" / "guardrails"),
467+
],
449468
)
450469

451470
assert result.exit_code == 0
@@ -458,7 +477,15 @@ def test_validate_then_publish_workflow(self, runner, sample_project, tmp_path):
458477
"""Test a complete validate -> publish workflow."""
459478
# First validate
460479
validate_result = runner.invoke(
461-
main, ["--telemetry", "none", "validate", str(sample_project)]
480+
main,
481+
[
482+
"--telemetry",
483+
"none",
484+
"validate",
485+
str(sample_project),
486+
"--guardrails-dir",
487+
str(sample_project / "lib" / "guardrails"),
488+
],
462489
)
463490

464491
# Then publish
@@ -482,7 +509,15 @@ def test_validate_and_lint_workflow(self, runner, sample_project):
482509
"""Test validate and lint commands on the same project."""
483510
# Validate
484511
validate_result = runner.invoke(
485-
main, ["--telemetry", "none", "validate", str(sample_project)]
512+
main,
513+
[
514+
"--telemetry",
515+
"none",
516+
"validate",
517+
str(sample_project),
518+
"--guardrails-dir",
519+
str(sample_project / "lib" / "guardrails"),
520+
],
486521
)
487522

488523
# Lint

xml_lib/lifecycle.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,37 @@ def validate_dag(dag: LifecycleDAG) -> ValidationResult:
213213
)
214214

215215
is_valid = len(errors) == 0
216+
217+
# Convert string errors to ValidationError objects
218+
error_objects = [
219+
ValidationError(
220+
file="",
221+
line=None,
222+
column=None,
223+
message=err,
224+
type="error",
225+
rule="lifecycle-validation",
226+
)
227+
for err in errors
228+
]
229+
230+
# Convert string warnings to ValidationError objects
231+
warning_objects = [
232+
ValidationError(
233+
file="",
234+
line=None,
235+
column=None,
236+
message=warn,
237+
type="warning",
238+
rule="lifecycle-validation",
239+
)
240+
for warn in warnings
241+
]
242+
216243
return ValidationResult(
217244
is_valid=is_valid,
218-
errors=[], # Convert strings to ValidationError objects if needed
219-
warnings=[],
245+
errors=error_objects,
246+
warnings=warning_objects,
220247
)
221248

222249

0 commit comments

Comments
 (0)