def test_eq() -> None: s1 = Step("a", PerformAction("a"), timedelta()) s2 = Step("a", WaitForEvent("a", {"foo": "bla"}), timedelta()) s3 = Step("a", EmitEvent(Event("a", {"a": "b"})), timedelta()) s4 = Step("a", ExecuteCommand("echo hello"), timedelta()) assert s1 == Step("a", PerformAction("a"), timedelta()) assert s2 == Step("a", WaitForEvent("a", {"foo": "bla"}), timedelta()) assert s3 == Step("a", EmitEvent(Event("a", {"a": "b"})), timedelta()) assert s4 == Step("a", ExecuteCommand("echo hello"), timedelta()) trigger = [EventTrigger("start me up")] assert Workflow("a", "a", [s1, s2, s3, s4], trigger) == Workflow("a", "a", [s1, s2, s3, s4], trigger)
def test_workflow() -> Workflow: return Workflow( TaskDescriptorId("test_workflow"), "Speakable name of workflow", [ Step("start", PerformAction("start_collect"), timedelta(seconds=10)), Step("wait", WaitForEvent("godot", {"a": 1}), timedelta(seconds=10)), Step("emit_event", EmitEvent(Event("hello", {"a": 1})), timedelta(seconds=10)), Step("collect", PerformAction("collect"), timedelta(seconds=10)), Step("done", PerformAction("collect_done"), timedelta(seconds=10), StepErrorBehaviour.Stop), ], [EventTrigger("start me up")], )
def test_marshalling_step() -> None: roundtrip(Step("test", PerformAction("test"))) roundtrip(Step("test", WaitForEvent("test"), timedelta(seconds=19), StepErrorBehaviour.Stop))
def test_marshalling_step_action() -> None: roundtrip(PerformAction("test")) roundtrip(EmitEvent(Event("test", {"foo": "hello"}))) roundtrip(WaitForEvent("test", {"foo": "hello"})) roundtrip(ExecuteCommand("help"))