Skip to content

Commit

Permalink
fix TestList, add TestModifiedVars
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Jul 29, 2024
1 parent 0a718ad commit 8ff33f9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
30 changes: 30 additions & 0 deletions tests/functional/defer_state/test_modified_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,3 +1144,33 @@ def test_changed_semantic_model_contents(self, project):
write_file(modified_semantic_model_schema_yml, "models", "schema.yml")
results = run_dbt(["list", "-s", "state:modified", "--state", "./state"])
assert len(results) == 1


class TestModifiedVars(BaseModifiedState):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
"vars": {"my_var": 1},
}

@pytest.fixture(scope="class")
def models(self):
return {
"view_model.sql": "select {{ var('my_var') }} as id",
}

def test_changed_vars(self, project):
self.run_and_save_state()

# No var change
assert not run_dbt(["list", "-s", "state:modified", "--state", "./state"])
assert not run_dbt(["list", "-s", "state:modified.vars", "--state", "./state"])

# Modify var (my_var: 1 -> 2
update_config_file({"vars": {"my_var": 2}}, "dbt_project.yml")
assert run_dbt(["list", "-s", "state:modified", "--state", "./state"]) == [
"test.view_model"
]
assert run_dbt(["list", "-s", "state:modified.vars", "--state", "./state"]) == [
"test.view_model"
]
20 changes: 16 additions & 4 deletions tests/functional/list/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def expect_snapshot_output(self, happy_path_project): # noqa: F811
"json": {
"name": "my_snapshot",
"package_name": "test",
"depends_on": {"nodes": [], "macros": []},
"depends_on": {
"nodes": [],
"macros": [],
"vars": {"target_database": happy_path_project.database},
},
"tags": [],
"config": {
"enabled": True,
Expand Down Expand Up @@ -96,7 +100,7 @@ def expect_analyses_output(self):
"json": {
"name": "a",
"package_name": "test",
"depends_on": {"nodes": [], "macros": []},
"depends_on": {"nodes": [], "macros": [], "vars": {}},
"tags": [],
"config": {
"enabled": True,
Expand Down Expand Up @@ -156,6 +160,7 @@ def expect_model_output(self):
"depends_on": {
"nodes": [],
"macros": ["macro.dbt.current_timestamp", "macro.dbt.date_trunc"],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -194,6 +199,7 @@ def expect_model_output(self):
"depends_on": {
"nodes": ["seed.test.seed"],
"macros": ["macro.dbt.is_incremental"],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -232,6 +238,7 @@ def expect_model_output(self):
"depends_on": {
"nodes": ["model.test.outer"],
"macros": [],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -270,6 +277,7 @@ def expect_model_output(self):
"depends_on": {
"nodes": [],
"macros": ["macro.dbt.current_timestamp", "macro.dbt.date_trunc"],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -308,6 +316,7 @@ def expect_model_output(self):
"depends_on": {
"nodes": [],
"macros": ["macro.dbt.current_timestamp", "macro.dbt.date_trunc"],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -346,6 +355,7 @@ def expect_model_output(self):
"depends_on": {
"nodes": ["model.test.ephemeral"],
"macros": [],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -399,7 +409,7 @@ def expect_model_ephemeral_output(self):
{
"name": "outer",
"package_name": "test",
"depends_on": {"nodes": [], "macros": []},
"depends_on": {"nodes": [], "macros": [], "vars": {}},
"tags": [],
"config": {
"enabled": True,
Expand Down Expand Up @@ -512,6 +522,7 @@ def expect_test_output(self):
"depends_on": {
"nodes": ["model.test.outer"],
"macros": ["macro.dbt.test_not_null"],
"vars": {},
},
"tags": [],
"config": {
Expand Down Expand Up @@ -540,7 +551,7 @@ def expect_test_output(self):
{
"name": "t",
"package_name": "test",
"depends_on": {"nodes": [], "macros": []},
"depends_on": {"nodes": [], "macros": [], "vars": {}},
"tags": [],
"config": {
"enabled": True,
Expand Down Expand Up @@ -571,6 +582,7 @@ def expect_test_output(self):
"depends_on": {
"nodes": ["model.test.outer"],
"macros": ["macro.dbt.test_unique"],
"vars": {},
},
"tags": [],
"config": {
Expand Down

0 comments on commit 8ff33f9

Please sign in to comment.