Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dojinkimm committed Aug 31, 2023
1 parent b0c2d9b commit 0f61f4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cosmos/dbt/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def load_via_custom_parser(self) -> None:
dbt_models_dir=self.project.models_dir.stem if self.project.models_dir else None,
dbt_seeds_dir=self.project.seeds_dir.stem if self.project.seeds_dir else None,
project_name=self.project.name,
operator_args=operator_args,
operator_args=self.operator_args,
)
nodes = {}
models = itertools.chain(project.models.items(), project.snapshots.items(), project.seeds.items())
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/parser/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,13 @@ def test_dbtmodelconfig_with_sources(tmp_path):

dbt_model = DbtModel(name="some_name", type=DbtModelType.DBT_MODEL, path=path_with_sources)
assert "sample_source" not in dbt_model.config.upstream_models


def test_dbtmodelconfig_with_vars(tmp_path):
model_sql = SAMPLE_MODEL_SQL_PATH.read_text()
model_with_sources_sql = model_sql.replace("ref('stg_customers_'~ var('country_code'))")
path_with_sources = tmp_path / "customers_with_sources.sql"
path_with_sources.write_text(model_with_sources_sql)

dbt_model = DbtModel(name="some_name", type=DbtModelType.DBT_MODEL, path=path_with_sources, operator_args={"vars": {"country_code": "us"}})
assert "stg_customers_us" in dbt_model.config.upstream_models

0 comments on commit 0f61f4c

Please sign in to comment.