Skip to content

Commit

Permalink
deflake source freshness hooks test (#10308)
Browse files Browse the repository at this point in the history
(cherry picked from commit d4a6482)
  • Loading branch information
MichelleArk authored and github-actions[bot] committed Jun 13, 2024
1 parent c31522e commit 73b1e49
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions tests/functional/sources/test_source_freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
):
Expand All @@ -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):
Expand All @@ -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,
):
Expand All @@ -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)

0 comments on commit 73b1e49

Please sign in to comment.