def test_set_upstream_no_flow(self): f = Flow(name="test") t1 = Task() t2 = Task() with pytest.raises(ValueError) as exc: t2.set_upstream(t1) assert "No Flow was passed" in str(exc.value)
def test_serialize_flow_sorts_nested_schemas(): a = Parameter("a", default=1) b = Parameter("b", default=2) c = Task("c") d = Task("d") f = Flow("test") d.set_upstream(c, flow=f) c.set_upstream(b, flow=f).set_upstream(a, flow=f) f.set_reference_tasks([d, c]) # Must use `f.serialize` instead of `FlowSchema().dump` because task slugs # are not guaranteed to be set yet serialized = f.serialize() assert [param["slug"] for param in serialized["parameters"]] == ["a", "b"] assert [task["slug"] for task in serialized["tasks"]] == ["a", "b", "c-1", "d-1"] assert [ (edge["upstream_task"]["slug"], edge["downstream_task"]["slug"]) for edge in serialized["edges"] ] == [("a", "c-1"), ("b", "c-1"), ("c-1", "d-1")] assert [task["slug"] for task in serialized["reference_tasks"]] == ["c-1", "d-1"]
def test_set_upstream_with_properties(self, props): with Flow(name="test") as f: t1 = Task() t2 = Task() t2.set_upstream(t1, **props) assert Edge(t1, t2, **props) in f.edges
def test_set_upstream_no_flow(self): f = Flow(name="test") t1 = Task() t2 = Task() with pytest.raises(ValueError, match="No Flow was passed"): t2.set_upstream(t1)
def test_set_upstream_context(self): with Flow(name="test") as f: t1 = Task() t2 = Task() t2.set_upstream(t1) assert Edge(t1, t2) in f.edges
def test_set_upstream(self): f = Flow(name="test") t1 = Task() t2 = Task() t2.set_upstream(t1, flow=f) assert Edge(t1, t2) in f.edges