From 0f61f4c23973317b56cbf00579e4c8d7daa26229 Mon Sep 17 00:00:00 2001 From: dojinkimm Date: Thu, 31 Aug 2023 23:27:51 +0900 Subject: [PATCH] Add test --- cosmos/dbt/graph.py | 2 +- tests/dbt/parser/test_project.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cosmos/dbt/graph.py b/cosmos/dbt/graph.py index 44f7df25a..85a2e0d8a 100644 --- a/cosmos/dbt/graph.py +++ b/cosmos/dbt/graph.py @@ -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()) diff --git a/tests/dbt/parser/test_project.py b/tests/dbt/parser/test_project.py index 1a3d66f83..d4177e82e 100644 --- a/tests/dbt/parser/test_project.py +++ b/tests/dbt/parser/test_project.py @@ -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