-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test of metadata-based freshness mechanism
- Loading branch information
1 parent
e39a6e7
commit 010c781
Showing
2 changed files
with
34 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
33 changes: 33 additions & 0 deletions
33
tests/functional/adapter/test_get_last_relation_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,33 @@ | ||
import os | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
freshness_via_metadata_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_TEST_SCHEMA_NAME_VARIABLE') }}" | ||
tables: | ||
- name: test_table | ||
""" | ||
|
||
|
||
class TestGetLastRelationModified: | ||
@pytest.fixture(scope="class", autouse=True) | ||
def set_env_vars(self, project): | ||
os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"] = project.test_schema | ||
yield | ||
del os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"] | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"schema.yml": freshness_via_metadata_schema_yml} | ||
|
||
def test_get_last_relation_modified(self, project, set_env_vars): | ||
project.run_sql( | ||
f"create table {project.test_schema}.test_table (id integer autoincrement, name varchar(100) not null);" | ||
) | ||
run_dbt(["source", "freshness"]) |