Exemplo n.º 1
0
    def test_sync(self, run_task_mock):
        run_task_mock.return_value = True

        executor = DebugExecutor()

        ti1 = MagicMock(key="t1")
        ti2 = MagicMock(key="t2")
        executor.tasks_to_run = [ti1, ti2]

        executor.sync()
        assert not executor.tasks_to_run
        run_task_mock.assert_has_calls([mock.call(ti1), mock.call(ti2)])
Exemplo n.º 2
0
    def test_fail_fast(self, change_state_mock):
        with mock.patch.dict("os.environ",
                             {"AIRFLOW__DEBUG__FAIL_FAST": "True"}):
            executor = DebugExecutor()

        ti1 = MagicMock(key="t1")
        ti2 = MagicMock(key="t2")

        ti1._run_raw_task.side_effect = Exception

        executor.tasks_to_run = [ti1, ti2]

        executor.sync()

        assert executor.fail_fast
        assert not executor.tasks_to_run
        change_state_mock.assert_has_calls([
            mock.call(ti1.key, State.FAILED),
            mock.call(ti2.key, State.UPSTREAM_FAILED),
        ])