-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add metadata-based source freshness for a relation
- Loading branch information
1 parent
440b896
commit 1ae71ba
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SCHEMA_YML = """version: 2 | ||
sources: | ||
- name: test_source | ||
freshness: | ||
warn_after: {count: 10, period: hour} | ||
error_after: {count: 1, period: day} | ||
schema: "{{ env_var('DBT_GET_LAST_RELATION_TEST_SCHEMA') }}" | ||
tables: | ||
- name: test_source | ||
""" | ||
|
||
SEED_TEST_SOURCE_CSV = """ | ||
id,name | ||
1,Martin | ||
2,Jeter | ||
3,Ruth | ||
4,Gehrig | ||
5,DiMaggio | ||
6,Torre | ||
7,Mantle | ||
8,Berra | ||
9,Maris | ||
""".strip() |
30 changes: 30 additions & 0 deletions
30
tests/functional/adapter/sources_freshness_tests/test_get_relation_last_modified.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
from tests.functional.adapter.sources_freshness_tests import files | ||
|
||
|
||
class TestGetLastRelationModified: | ||
@pytest.fixture(scope="class") | ||
def seeds(self): | ||
return {"test_source.csv": files.SEED_TEST_SOURCE_CSV} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"schema.yml": files.SCHEMA_YML} | ||
|
||
@pytest.fixture(scope="class", autouse=True) | ||
def setup(self, project): | ||
# we need the schema name for the sources section | ||
os.environ["DBT_GET_LAST_RELATION_TEST_SCHEMA"] = project.test_schema | ||
run_dbt(["seed"]) | ||
yield | ||
del os.environ["DBT_GET_LAST_RELATION_TEST_SCHEMA"] | ||
|
||
def test_get_last_relation_modified(self, project, setup): | ||
results = run_dbt(["source", "freshness"]) | ||
assert len(results) == 1 | ||
result = results[0] | ||
assert result.status == "pass" |