Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/automation/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified src/automation/__pycache__/components.cpython-312.pyc
Binary file not shown.
Binary file modified src/automation/__pycache__/engine.cpython-312.pyc
Binary file not shown.
Binary file modified src/automation/__pycache__/variables.cpython-312.pyc
Binary file not shown.
83 changes: 83 additions & 0 deletions tests/test_automation_review_regressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from automation import __doc__ as automation_doc
from automation.components import Component, ComponentInput, ComponentRegistry, FunctionComponent
from automation.engine import AutomationDefinition, AutomationEngine, RunStatus
from automation.variables import GeneratorVariable


def test_collect_includes_peeked_value():
variable = GeneratorVariable.from_iterable([1, 2, 3])

assert variable.peek() == 1
assert variable.collect() == [1, 2, 3]
Comment on lines +7 to +11


class LifecycleHelperComponent(Component):
def __init__(self, events, label):
self._events = events
self._label = label

def setup(self) -> None:
self._events.append(f"{self._label}-setup")

def teardown(self) -> None:
self._events.append(f"{self._label}-teardown")

def execute(self, input_: ComponentInput):
return self._ok(input_.payload)


def test_register_replaces_component_with_teardown():
events = []
registry = ComponentRegistry()

registry.register("step", LifecycleHelperComponent(events, "old"))
registry.register("step", LifecycleHelperComponent(events, "new"))
assert registry.deregister("step") is True

assert events == ["old-setup", "old-teardown", "new-setup", "new-teardown"]


def test_function_component_returns_traceback_on_failure():
def broken(input_):
assert input_.name == "broken"
raise RuntimeError("boom")

output = FunctionComponent(broken, name="broken").execute(
ComponentInput(name="broken", payload=None)
)

assert output.success is False
assert output.error is not None
assert "Traceback" in output.error
assert "RuntimeError: boom" in output.error


def test_missing_variables_fail_run_instead_of_being_silently_dropped():
engine = AutomationEngine()
engine.register_fn("echo", lambda input_: input_.payload)
engine.define(
AutomationDefinition(
name="uses-missing-variable",
triggers=["demo"],
steps=["echo"],
variables=["missing"],
)
)

results = engine.trigger_type("demo", payload="hello")

assert len(results) == 1
result = results[0]
assert result.status is RunStatus.FAILED
assert result.error is not None
assert "KeyError" in result.error
assert "Variable 'missing' not found in registry" in result.error
assert result.outputs[0].component == "__engine__"
assert result.outputs[0].success is False


def test_quick_start_uses_package_imports():
assert isinstance(automation_doc, str)
assert automation_doc.strip()
assert "from automation import AutomationEngine" in automation_doc
assert "from src.automation import" not in automation_doc
Comment on lines +79 to +83

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Docstring test brittleness 🐞 Bug ☼ Reliability

test_quick_start_uses_package_imports hard-requires automation.__doc__ to be a non-empty str and to
contain specific text, so it can fail in environments where docstrings are stripped or if the
quick-start formatting changes without changing the intended import contract. This makes the
regression coverage less reliable than necessary.
Agent Prompt
### Issue description
`test_quick_start_uses_package_imports` asserts against `automation.__doc__` directly. This couples the test to runtime docstring availability and exact formatting, making it easy to fail in certain execution modes or after harmless docstring edits.

### Issue Context
The quick-start content is defined in the module docstring of `src/automation/__init__.py`. The regression goal is to ensure the *example imports* reference `automation` (package import) rather than `src.automation`.

### Fix Focus Areas
- tests/test_automation_review_regressions.py[1-4]
- tests/test_automation_review_regressions.py[79-83]

### Suggested fix
Update the test to assert against the module *source text* instead of `__doc__`, e.g.:
- `import automation, pathlib`
- `text = pathlib.Path(automation.__file__).read_text(encoding="utf-8")`
- Assert the expected quick-start import lines are present/absent within `text`.

(Alternative: if you intentionally want to validate the runtime docstring, add a guard like `if automation_doc is None: pytest.skip(...)`.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fsspec, black, tox?

Loading