Skip to content

Commit

Permalink
Add more unit test to cover debug executor (apache#35400)
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen-CH-Leung authored Nov 3, 2023
1 parent 10bac85 commit 3d23bf9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion scripts/cov/core_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

files_not_fully_covered = [
# executors
"airflow/executors/debug_executor.py",
"airflow/executors/executor_loader.py",
"airflow/executors/local_executor.py",
"airflow/executors/sequential_executor.py",
Expand Down
24 changes: 24 additions & 0 deletions tests/executors/test_debug_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,27 @@ def test_is_single_threaded(self):

def test_is_production_default_value(self):
assert not DebugExecutor.is_production

@mock.patch("time.sleep", autospec=True)
def test_trigger_sleep_when_no_task(self, mock_sleep):
execute_mock = MagicMock()
executor = DebugExecutor()
executor.execute_async = execute_mock
executor.queued_tasks = {}
executor.trigger_tasks(open_slots=5)
mock_sleep.assert_called()

@mock.patch("airflow.executors.debug_executor.DebugExecutor.change_state")
def test_sync_after_terminate(self, change_state_mock):
executor = DebugExecutor()

ti1 = MagicMock(key="t1")
executor.tasks_to_run = [ti1]
executor.terminate()
executor.sync()

change_state_mock.assert_has_calls(
[
mock.call(ti1.key, State.FAILED),
]
)

0 comments on commit 3d23bf9

Please sign in to comment.