From e97d6f4695a9c16d0e559bb37aecc5e9f9e3595a Mon Sep 17 00:00:00 2001 From: Tatiana Al-Chueyr Date: Tue, 26 Sep 2023 23:54:40 +0100 Subject: [PATCH] Add test for when callback is not called --- tests/operators/test_local.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/operators/test_local.py b/tests/operators/test_local.py index 223305fbe..c41a627fb 100644 --- a/tests/operators/test_local.py +++ b/tests/operators/test_local.py @@ -225,6 +225,31 @@ def test_run_test_operator_with_callback(failing_test_dbt_project): assert on_warning_callback.called +@pytest.mark.integration +def test_run_test_operator_without_callback(): + on_warning_callback = MagicMock() + + with DAG("test-id-3", start_date=datetime(2022, 1, 1)) as dag: + run_operator = DbtRunLocalOperator( + profile_config=real_profile_config, + project_dir=DBT_PROJ_DIR, + task_id="run", + dbt_cmd_flags=["--models", "orders"], + install_deps=True, + ) + test_operator = DbtTestLocalOperator( + profile_config=real_profile_config, + project_dir=DBT_PROJ_DIR, + task_id="test", + dbt_cmd_flags=["--models", "orders"], + install_deps=True, + exclude="relationships_orders_customer_id__customer_id__ref_customers_", + ) + run_operator >> test_operator + run_test_dag(dag) + assert not on_warning_callback.called + + @pytest.mark.integration def test_run_operator_emits_events(): class MockRun: