def test_on_finish_crashes_gracefully(tmp_directory): dag = DAG() PythonCallable(touch_root, File('file.txt'), dag, name='t') dag.on_finish = early_stop assert dag.build() is None assert dag._exec_status == DAGStatus.Errored
def test_on_finish_hook_is_executed(tmp_directory): hook.count = 0 dag = DAG() PythonCallable(touch_root, File('file.txt'), dag, name='t') dag.on_finish = hook dag.build() assert hook.count == 1
def test_on_finish(): on_finish_hook.count = 0 on_finish_hook.report = None dag = DAG() dag.on_finish = on_finish_hook report = dag.build() assert on_finish_hook.count == 1 # check report parameter sent is the same as the one returned assert report is on_finish_hook.report
def test_on_finish_crashes(tmp_directory): dag = DAG() PythonCallable(touch_root, File('file.txt'), dag, name='t') dag.on_finish = hook_crashing with pytest.raises(DAGBuildError) as excinfo: dag.build() msg = 'Exception when running on_finish for DAG "No name": crash!' assert str(excinfo.value) == msg assert 'crash!' in str(excinfo.getrepr()) assert dag._exec_status == DAGStatus.Errored