forked from genewildish/Mainline
fix lint: combine with statements
This commit is contained in:
@@ -1772,3 +1772,73 @@ class TestPipelineMutation:
|
||||
result = pipeline.execute(None)
|
||||
assert result.success
|
||||
assert call_log == ["source", "display"]
|
||||
|
||||
|
||||
class TestAutoInjection:
|
||||
"""Tests for auto-injection of minimum capabilities."""
|
||||
|
||||
def setup_method(self):
|
||||
"""Reset registry before each test."""
|
||||
StageRegistry._discovered = False
|
||||
StageRegistry._categories.clear()
|
||||
StageRegistry._instances.clear()
|
||||
discover_stages()
|
||||
|
||||
def test_auto_injection_provides_minimum_capabilities(self):
|
||||
"""Pipeline with no stages gets minimum capabilities auto-injected."""
|
||||
pipeline = Pipeline()
|
||||
# Don't add any stages
|
||||
pipeline.build(auto_inject=True)
|
||||
|
||||
# Should have stages for source, render, camera, display
|
||||
assert len(pipeline.stages) > 0
|
||||
assert "source" in pipeline.stages
|
||||
assert "display" in pipeline.stages
|
||||
|
||||
def test_auto_injection_rebuilds_execution_order(self):
|
||||
"""Auto-injection rebuilds execution order correctly."""
|
||||
pipeline = Pipeline()
|
||||
pipeline.build(auto_inject=True)
|
||||
|
||||
# Execution order should be valid
|
||||
assert len(pipeline.execution_order) > 0
|
||||
# Source should come before display
|
||||
source_idx = pipeline.execution_order.index("source")
|
||||
display_idx = pipeline.execution_order.index("display")
|
||||
assert source_idx < display_idx
|
||||
|
||||
def test_validation_error_after_auto_injection(self):
|
||||
"""Pipeline raises error if auto-injection fails to provide capabilities."""
|
||||
from unittest.mock import patch
|
||||
|
||||
pipeline = Pipeline()
|
||||
|
||||
# Mock ensure_minimum_capabilities to return empty list (injection failed)
|
||||
with (
|
||||
patch.object(pipeline, "ensure_minimum_capabilities", return_value=[]),
|
||||
patch.object(
|
||||
pipeline,
|
||||
"validate_minimum_capabilities",
|
||||
return_value=(False, ["source"]),
|
||||
),
|
||||
):
|
||||
# Even though injection "ran", it didn't provide the capability
|
||||
# build() should raise StageError
|
||||
with pytest.raises(StageError) as exc_info:
|
||||
pipeline.build(auto_inject=True)
|
||||
|
||||
assert "Auto-injection failed" in str(exc_info.value)
|
||||
|
||||
def test_minimum_capability_removal_recovery(self):
|
||||
"""Pipeline re-injects minimum capability if removed."""
|
||||
pipeline = Pipeline()
|
||||
pipeline.build(auto_inject=True)
|
||||
|
||||
# Remove the display stage
|
||||
pipeline.remove_stage("display", cleanup=True)
|
||||
|
||||
# Rebuild with auto-injection
|
||||
pipeline.build(auto_inject=True)
|
||||
|
||||
# Display should be back
|
||||
assert "display" in pipeline.stages
|
||||
|
||||
Reference in New Issue
Block a user