Skip to content

Commit f548ecb

Browse files
committed
Fix pytest mocks
1 parent 36cca3a commit f548ecb

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

airflow-core/tests/unit/jobs/test_scheduler_job.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,7 +3147,7 @@ def test_dagrun_timeout_fails_run_and_update_next_dagrun(self, dag_maker):
31473147
@pytest.mark.parametrize(
31483148
("state", "expected_callback_msg"), [(State.SUCCESS, "success"), (State.FAILED, "task_failure")]
31493149
)
3150-
@conf_vars({("scheduler", "use_job_schedule"): False})
3150+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
31513151
def test_dagrun_callbacks_are_called(self, state, expected_callback_msg, dag_maker, session):
31523152
"""
31533153
Test if DagRun is successful, and if Success callbacks is defined, it is sent to DagFileProcessor.
@@ -3192,7 +3192,7 @@ def test_dagrun_callbacks_are_called(self, state, expected_callback_msg, dag_mak
31923192
@pytest.mark.parametrize(
31933193
("state", "expected_callback_msg"), [(State.SUCCESS, "success"), (State.FAILED, "task_failure")]
31943194
)
3195-
@conf_vars({("scheduler", "use_job_schedule"): False})
3195+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
31963196
def test_dagrun_plugins_are_notified(self, state, expected_callback_msg, dag_maker, session):
31973197
"""
31983198
Test if DagRun is successful, and if Success callbacks is defined, it is sent to DagFileProcessor.
@@ -3225,7 +3225,7 @@ def test_dagrun_plugins_are_notified(self, state, expected_callback_msg, dag_mak
32253225

32263226
session.rollback()
32273227

3228-
@conf_vars({("scheduler", "use_job_schedule"): False})
3228+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
32293229
def test_dagrun_timeout_callbacks_are_stored_in_database(self, dag_maker, session):
32303230
with dag_maker(
32313231
dag_id="test_dagrun_timeout_callbacks_are_stored_in_database",
@@ -3266,7 +3266,7 @@ def test_dagrun_timeout_callbacks_are_stored_in_database(self, dag_maker, sessio
32663266

32673267
assert callback == expected_callback
32683268

3269-
@conf_vars({("scheduler", "use_job_schedule"): False})
3269+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
32703270
def test_dagrun_callbacks_commited_before_sent(self, dag_maker):
32713271
"""
32723272
Tests that before any callbacks are sent to the processor, the session is committed. This ensures
@@ -3312,7 +3312,7 @@ def mock_send_dag_callbacks_to_processor(*args, **kwargs):
33123312
session.close()
33133313

33143314
@pytest.mark.parametrize("state", [State.SUCCESS, State.FAILED])
3315-
@conf_vars({("scheduler", "use_job_schedule"): False})
3315+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
33163316
def test_dagrun_callbacks_are_not_added_when_callbacks_are_not_defined(self, state, dag_maker, session):
33173317
"""
33183318
Test if no on_*_callback are defined on DAG, Callbacks not registered and sent to DAG Processor
@@ -3343,7 +3343,7 @@ def test_dagrun_callbacks_are_not_added_when_callbacks_are_not_defined(self, sta
33433343
session.rollback()
33443344

33453345
@pytest.mark.parametrize(("state", "msg"), [[State.SUCCESS, "success"], [State.FAILED, "task_failure"]])
3346-
@conf_vars({("scheduler", "use_job_schedule"): False})
3346+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
33473347
def test_dagrun_callbacks_are_added_when_callbacks_are_defined(self, state, msg, dag_maker):
33483348
"""
33493349
Test if on_*_callback are defined on DAG, Callbacks ARE registered and sent to DAG Processor
@@ -3376,7 +3376,7 @@ def test_dagrun_callbacks_are_added_when_callbacks_are_defined(self, state, msg,
33763376
session.rollback()
33773377
session.close()
33783378

3379-
@conf_vars({("scheduler", "use_job_schedule"): False})
3379+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
33803380
def test_dagrun_notify_called_success(self, dag_maker):
33813381
with dag_maker(
33823382
dag_id="test_dagrun_notify_called",
@@ -5994,7 +5994,7 @@ def test_start_queued_dagruns_do_follow_logical_date_order(self, dag_maker):
59945994

59955995
assert dr[0].state == State.RUNNING
59965996

5997-
@conf_vars({("scheduler", "use_job_schedule"): False})
5997+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
59985998
def test_no_dagruns_would_stuck_in_running(self, dag_maker):
59995999
# Test that running dagruns are not stuck in running.
60006000
# Create one dagrun in 'running' state and 1 in 'queued' state from one dag(max_active_runs=1)
@@ -6635,7 +6635,7 @@ def test_task_instance_heartbeat_timeout_message(self, session, create_dagrun):
66356635
"External Executor Id": "abcdefg",
66366636
}
66376637

6638-
@conf_vars({("scheduler", "use_job_schedule"): False})
6638+
@conf_vars({("scheduler", "use_job_schedule"): "False"})
66396639
def run_scheduler_until_dagrun_terminal(self):
66406640
"""
66416641
Run a scheduler until any dag run reaches a terminal state, or the scheduler becomes "idle".

airflow-core/tests/unit/models/test_serialized_dag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from airflow.utils.types import DagRunTriggeredByType, DagRunType
4747

4848
from tests_common.test_utils import db
49+
from tests_common.test_utils.config import conf_vars
4950
from tests_common.test_utils.dag import create_scheduler_dag, sync_dag_to_db
5051

5152
logger = logging.getLogger(__name__)
@@ -90,7 +91,7 @@ def setup_test_cases(self, request, monkeypatch):
9091
db.clear_db_dags()
9192
db.clear_db_runs()
9293
db.clear_db_serialized_dags()
93-
with mock.patch("airflow.models.serialized_dag.COMPRESS_SERIALIZED_DAGS", request.param):
94+
with conf_vars({("core", "compress_serialized_dags"): str(request.param)}):
9495
yield
9596
db.clear_db_serialized_dags()
9697

0 commit comments

Comments
 (0)