Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix source resource type tests #1405

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dev/dags/dbt/altered_jaffle_shop/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'jaffle_shop'
name: 'altered_jaffle_shop'

config-version: 2
version: '0.1'

profile: 'jaffle_shop'
profile: 'postgres_profile'

model-paths: ["models"]
seed-paths: ["seeds"]
Expand All @@ -20,7 +20,7 @@ clean-targets:
require-dbt-version: [">=1.0.0", "<2.0.0"]

models:
jaffle_shop:
altered_jaffle_shop:
materialized: table
staging:
materialized: view
2 changes: 1 addition & 1 deletion dev/dags/dbt/altered_jaffle_shop/models/orders.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(
materialized='view',
materialized='table',
alias=var('orders_alias', 'orders')
)
}}
Expand Down
2 changes: 1 addition & 1 deletion dev/dags/example_cosmos_dbt_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
example_cosmos_dbt_build = DbtDag(
# dbt/cosmos-specific parameters
project_config=ProjectConfig(
DBT_ROOT_PATH / "jaffle_shop",
DBT_ROOT_PATH / "altered_jaffle_shop",
),
render_config=RenderConfig(
test_behavior=TestBehavior.BUILD,
Expand Down
2 changes: 1 addition & 1 deletion dev/dags/example_source_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
source_rendering_dag = DbtDag(
# dbt/cosmos-specific parameters
project_config=ProjectConfig(
DBT_ROOT_PATH / "jaffle_shop",
DBT_ROOT_PATH / "altered_jaffle_shop",
),
profile_config=profile_config,
operator_args={
Expand Down
42 changes: 21 additions & 21 deletions tests/dbt/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,26 +494,26 @@ def test_load_via_dbt_ls_with_exclude(postgres_profile_config):
# This test is dependent upon dbt >= 1.5.4
assert len(dbt_graph.nodes) == 9
expected_keys = [
"model.jaffle_shop.customers",
"model.jaffle_shop.stg_customers",
"seed.jaffle_shop.raw_customers",
"test.jaffle_shop.not_null_customers_customer_id.5c9bf9911d",
"test.jaffle_shop.not_null_stg_customers_customer_id.e2cfb1f9aa",
"test.jaffle_shop.source_not_null_postgres_db_raw_customers_id.de3e9fff76",
"test.jaffle_shop.source_unique_postgres_db_raw_customers_id.6e5ad1d707",
"test.jaffle_shop.unique_customers_customer_id.c5af1ff4b1",
"test.jaffle_shop.unique_stg_customers_customer_id.c7614daada",
"model.altered_jaffle_shop.customers",
"model.altered_jaffle_shop.stg_customers",
"seed.altered_jaffle_shop.raw_customers",
"test.altered_jaffle_shop.not_null_customers_customer_id.5c9bf9911d",
"test.altered_jaffle_shop.not_null_stg_customers_customer_id.e2cfb1f9aa",
"test.altered_jaffle_shop.source_not_null_postgres_db_raw_customers_id.de3e9fff76",
"test.altered_jaffle_shop.source_unique_postgres_db_raw_customers_id.6e5ad1d707",
"test.altered_jaffle_shop.unique_customers_customer_id.c5af1ff4b1",
"test.altered_jaffle_shop.unique_stg_customers_customer_id.c7614daada",
]
assert sorted(dbt_graph.nodes.keys()) == expected_keys

sample_node = dbt_graph.nodes["model.jaffle_shop.customers"]
sample_node = dbt_graph.nodes["model.altered_jaffle_shop.customers"]
assert sample_node.name == "customers"
assert sample_node.unique_id == "model.jaffle_shop.customers"
assert sample_node.unique_id == "model.altered_jaffle_shop.customers"
assert sample_node.resource_type == DbtResourceType.MODEL
assert sample_node.depends_on == [
"model.jaffle_shop.stg_customers",
"model.jaffle_shop.stg_orders",
"model.jaffle_shop.stg_payments",
"model.altered_jaffle_shop.stg_customers",
"model.altered_jaffle_shop.stg_orders",
"model.altered_jaffle_shop.stg_payments",
]
assert sample_node.file_path == DBT_PROJECTS_ROOT_DIR / ALTERED_DBT_PROJECT_NAME / "models/customers.sql"

Expand Down Expand Up @@ -632,8 +632,8 @@ def test_load_via_dbt_ls_with_sources(load_method):
)
getattr(dbt_graph, load_method)()
assert len(dbt_graph.nodes) >= 4
assert "source.jaffle_shop.postgres_db.raw_customers" in dbt_graph.nodes
assert "exposure.jaffle_shop.weekly_metrics" in dbt_graph.nodes
assert "source.altered_jaffle_shop.postgres_db.raw_customers" in dbt_graph.nodes
assert "exposure.altered_jaffle_shop.weekly_metrics" in dbt_graph.nodes


@pytest.mark.integration
Expand Down Expand Up @@ -1442,7 +1442,7 @@ def test_load_via_dbt_ls_with_project_config_vars():
),
)
dbt_graph.load_via_dbt_ls()
assert dbt_graph.nodes["model.jaffle_shop.orders"].config["alias"] == "orders"
assert dbt_graph.nodes["model.altered_jaffle_shop.orders"].config["alias"] == "orders"


@pytest.mark.integration
Expand Down Expand Up @@ -1482,12 +1482,12 @@ def test_load_via_dbt_ls_with_selector_arg(tmp_altered_dbt_project_dir, postgres

filtered_nodes = dbt_graph.filtered_nodes.keys()
assert len(filtered_nodes) == 7
assert "model.jaffle_shop.stg_customers" in filtered_nodes
assert "seed.jaffle_shop.raw_customers" in filtered_nodes
assert "model.altered_jaffle_shop.stg_customers" in filtered_nodes
assert "seed.altered_jaffle_shop.raw_customers" in filtered_nodes
if SOURCE_RENDERING_BEHAVIOR == SourceRenderingBehavior.ALL:
assert "source.jaffle_shop.postgres_db.raw_customers" in filtered_nodes
assert "source.altered_jaffle_shop.postgres_db.raw_customers" in filtered_nodes
# Four tests should be filtered
assert sum(node.startswith("test.jaffle_shop") for node in filtered_nodes) == 4
assert sum(node.startswith("test.altered_jaffle_shop") for node in filtered_nodes) == 4


@pytest.mark.parametrize(
Expand Down
Loading
Loading