-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include py.typed in MANIFEST.in (#5703)
This enables packages that install dbt-core from pypi to use mypy.
- Loading branch information
Showing
3 changed files
with
20,078 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
77 changes: 77 additions & 0 deletions
77
tests/functional/schema_management/test_drop_dangling_models.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,77 @@ | ||
import pytest | ||
import os | ||
|
||
from dbt.tests.util import ( | ||
run_dbt, | ||
check_table_does_exist, | ||
check_table_does_not_exist, | ||
) | ||
|
||
model = """ | ||
{{ | ||
config( | ||
materialized = "table" | ||
) | ||
}} | ||
SELECT * FROM ( | ||
VALUES (1, 'one'), | ||
(2, 'two'), | ||
(3, 'three') | ||
) AS t (num,letter) | ||
""" | ||
|
||
|
||
|
||
class TestDanglingModels: | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"model_a.sql": model, | ||
"model_b.sql": model, | ||
} | ||
|
||
|
||
@pytest.fixture(scope="class") | ||
def dbt_profile_target(self): | ||
return { | ||
"type": "postgres", | ||
"threads": 4, | ||
"host": "localhost", | ||
"port": int(os.getenv("POSTGRES_TEST_PORT", 5432)), | ||
"user": os.getenv("POSTGRES_TEST_USER", "root"), | ||
"pass": os.getenv("POSTGRES_TEST_PASS", "password"), | ||
"dbname": os.getenv("POSTGRES_TEST_DATABASE", "dbt"), | ||
"manage_schemas": True, | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def project_config_update(self, unique_schema): | ||
return { | ||
"managed-schemas": [ | ||
{ | ||
"database": os.getenv("POSTGRES_TEST_DATABASE", "dbt"), | ||
"schema": unique_schema, | ||
"action": "drop", | ||
} | ||
] | ||
} | ||
|
||
|
||
def test_drop( | ||
self, | ||
project, | ||
): | ||
# create numbers model | ||
run_dbt(["run"]) | ||
check_table_does_exist(project.adapter, "model_a") | ||
check_table_does_exist(project.adapter, "model_b") | ||
check_table_does_not_exist(project.adapter, "baz") | ||
|
||
# remove numbers model | ||
project.update_models({ | ||
"model_b.sql": model, | ||
}) | ||
run_dbt(["run"]) | ||
check_table_does_not_exist(project.adapter, "model_a") | ||
check_table_does_exist(project.adapter, "model_b") |
Oops, something went wrong.