def test_validate_cycles(): f = Flow(name="test") t1 = Task() t2 = Task() f.add_edge(t1, t2) f.add_edge(t2, t1) with pytest.raises(ValueError) as exc: f.validate() assert "cycle found" in str(exc.value).lower()
def test_validate_missing_edge_upstream_tasks(): f = Flow(name="test") t1 = Task() t2 = Task() f.add_edge(t1, t2) f.tasks.remove(t1) with pytest.raises(ValueError) as exc: f.validate() assert "edges refer to tasks" in str(exc.value).lower()
def test_validate_missing_reference_tasks(): f = Flow(name="test") t1 = Task() t2 = Task() f.add_task(t1) f.add_task(t2) f.set_reference_tasks([t1]) f.tasks.remove(t1) with pytest.raises(ValueError) as exc: f.validate() assert "reference tasks are not contained" in str(exc.value).lower()
def test_eager_cycle_detection_defaults_false(): assert not prefect.config.flows.eager_edge_validation f = Flow(name="test") t1 = Task() t2 = Task() f.add_edge(t1, t2) # no cycle detected assert f.add_edge(t2, t1) with pytest.raises(ValueError): f.validate()