diff --git a/tests/functional/sources/test_source_freshness.py b/tests/functional/sources/test_source_freshness.py index b5c04c58e86..bef8c250488 100644 --- a/tests/functional/sources/test_source_freshness.py +++ b/tests/functional/sources/test_source_freshness.py @@ -127,6 +127,14 @@ def _assert_freshness_results(self, path, state): } ] + def _assert_project_hooks_called(self, logs: str): + assert "Running 1 on-run-start hook" in logs + assert "Running 1 on-run-end hook" in logs + + def _assert_project_hooks_not_called(self, logs: str): + assert "Running 1 on-run-start hook" not in logs + assert "Running 1 on-run-end hook" not in logs + class TestSourceFreshness(SuccessfulSourceFreshnessTest): def test_source_freshness(self, project): @@ -427,11 +435,17 @@ def project_config_update(self): }, } + @pytest.fixture(scope="class") + def global_deprecations(self): + deprecations.reset_deprecations() + yield + deprecations.reset_deprecations() + def test_hooks_do_run_for_source_freshness( self, project, + global_deprecations, ): - deprecations.reset_deprecations() assert deprecations.active_deprecations == set() _, log_output = self.run_dbt_and_capture_with_vars( project, @@ -471,8 +485,8 @@ def test_hooks_do_run_for_source_freshness( ], expect_pass=False, ) - assert "on-run-start" in log_output - assert "on-run-end" in log_output + + self._assert_project_hooks_called(log_output) class TestHooksInSourceFreshnessError: @@ -525,7 +539,7 @@ def project_config_update(self): }, } - def test_hooks_do_run_for_source_freshness( + def test_hooks_do_not_run_for_source_freshness( self, project, ): @@ -537,8 +551,7 @@ def test_hooks_do_run_for_source_freshness( ], expect_pass=False, ) - assert "on-run-start" not in log_output - assert "on-run-end" not in log_output + self._assert_project_hooks_not_called(log_output) class TestHooksInSourceFreshnessDefault(SuccessfulSourceFreshnessTest): @@ -550,7 +563,7 @@ def project_config_update(self): "on-run-end": ["{{ log('on-run-end hooks called') }}"], } - def test_hooks_do_run_for_source_freshness( + def test_hooks_do_not_run_for_source_freshness( self, project, ): @@ -563,5 +576,4 @@ def test_hooks_do_run_for_source_freshness( expect_pass=False, ) # default behaviour - no hooks run in source freshness - assert "on-run-start" not in log_output - assert "on-run-end" not in log_output + self._assert_project_hooks_not_called(log_output)