(self)
| 1723 | """Test the switch step type.""" |
| 1724 | |
| 1725 | def test_execute_matches_case(self): |
| 1726 | from specify_cli.workflows.steps.switch import SwitchStep |
| 1727 | from specify_cli.workflows.base import StepContext |
| 1728 | |
| 1729 | step = SwitchStep() |
| 1730 | ctx = StepContext( |
| 1731 | steps={"review": {"output": {"choice": "approve"}}} |
| 1732 | ) |
| 1733 | config = { |
| 1734 | "id": "route", |
| 1735 | "expression": "{{ steps.review.output.choice }}", |
| 1736 | "cases": { |
| 1737 | "approve": [{"id": "plan", "command": "speckit.plan"}], |
| 1738 | "reject": [{"id": "log", "type": "shell", "run": "echo rejected"}], |
| 1739 | }, |
| 1740 | "default": [{"id": "abort", "type": "gate", "message": "Unknown"}], |
| 1741 | } |
| 1742 | result = step.execute(config, ctx) |
| 1743 | assert result.output["matched_case"] == "approve" |
| 1744 | assert result.next_steps[0]["id"] == "plan" |
| 1745 | |
| 1746 | def test_execute_falls_to_default(self): |
| 1747 | from specify_cli.workflows.steps.switch import SwitchStep |
nothing calls this directly
no test coverage detected