-
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.
setup tests for autorefresh; demonstrate current state works and futu…
…re state doesn't work
- Loading branch information
1 parent
db51b6e
commit a92538a
Showing
2 changed files
with
53 additions
and
0 deletions.
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
35 changes: 35 additions & 0 deletions
35
tests/functional/adapter/materialized_view_tests/test_auto_refresh.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,35 @@ | ||
from datetime import datetime | ||
|
||
import pytest | ||
from dbt.contracts.relation import RelationType | ||
from dbt.tests.adapter.materialized_view.auto_refresh import ( | ||
MaterializedViewAutoRefreshNoChanges, | ||
) | ||
|
||
from dbt.adapters.bigquery.relation import BigQueryRelation | ||
|
||
from tests.functional.adapter.materialized_view_tests import files | ||
|
||
|
||
class TestMaterializedViewAutoRefreshNoChanges(MaterializedViewAutoRefreshNoChanges): | ||
@pytest.fixture(scope="class", autouse=True) | ||
def seeds(self): | ||
yield {"my_seed.csv": files.MY_SEED} | ||
|
||
@pytest.fixture(scope="class", autouse=True) | ||
def models(self): | ||
yield { | ||
"auto_refresh_on.sql": files.MY_MATERIALIZED_VIEW_AUTOREFRESH_ON, | ||
"auto_refresh_off.sql": files.MY_MATERIALIZED_VIEW_AUTOREFRESH_OFF, | ||
} | ||
|
||
def last_refreshed(self, project, materialized_view: str) -> datetime: | ||
relation = BigQueryRelation.create( | ||
database=project.database, | ||
schema=project.test_schema, | ||
identifier=materialized_view, | ||
type=RelationType.MaterializedView, | ||
) | ||
with project.adapter.connection_named("__test"): | ||
last_refresh_results = project.adapter.get_bq_table(relation) | ||
return last_refresh_results.mview_last_refresh_time or last_refresh_results.created |