@@ -1606,6 +1606,7 @@ def test_on_run_start_end():
16061606 assert root_environment_statements .after_all == [
16071607 "JINJA_STATEMENT_BEGIN;\n {{ create_tables(schemas) }}\n JINJA_END;" ,
16081608 "JINJA_STATEMENT_BEGIN;\n DROP TABLE to_be_executed_last;\n JINJA_END;" ,
1609+ "JINJA_STATEMENT_BEGIN;\n {{ graph_usage() }}\n JINJA_END;" ,
16091610 ]
16101611
16111612 assert root_environment_statements .jinja_macros .root_package_name == "sushi"
@@ -1626,6 +1627,7 @@ def test_on_run_start_end():
16261627 snapshots = sushi_context .snapshots ,
16271628 runtime_stage = RuntimeStage .AFTER_ALL ,
16281629 environment_naming_info = EnvironmentNamingInfo (name = "dev" ),
1630+ engine_adapter = sushi_context .engine_adapter ,
16291631 )
16301632
16311633 assert rendered_before_all == [
@@ -1635,12 +1637,35 @@ def test_on_run_start_end():
16351637 ]
16361638
16371639 # The jinja macro should have resolved the schemas for this environment and generated corresponding statements
1638- assert sorted (rendered_after_all ) == sorted (
1639- [
1640- "CREATE OR REPLACE TABLE schema_table_snapshots__dev AS SELECT 'snapshots__dev' AS schema" ,
1641- "CREATE OR REPLACE TABLE schema_table_sushi__dev AS SELECT 'sushi__dev' AS schema" ,
1642- "DROP TABLE to_be_executed_last" ,
1643- ]
1640+ expected_statements = [
1641+ "CREATE OR REPLACE TABLE schema_table_snapshots__dev AS SELECT 'snapshots__dev' AS schema" ,
1642+ "CREATE OR REPLACE TABLE schema_table_sushi__dev AS SELECT 'sushi__dev' AS schema" ,
1643+ "DROP TABLE to_be_executed_last" ,
1644+ ]
1645+ assert sorted (rendered_after_all [:- 1 ]) == sorted (expected_statements )
1646+
1647+ # Assert the models with their materialisations are present in the rendered graph_table statement
1648+ graph_table_stmt = rendered_after_all [- 1 ]
1649+ assert "'model.sushi.simple_model_a' AS unique_id, 'table' AS materialized" in graph_table_stmt
1650+ assert "'model.sushi.waiters' AS unique_id, 'ephemeral' AS materialized" in graph_table_stmt
1651+ assert "'model.sushi.simple_model_b' AS unique_id, 'table' AS materialized" in graph_table_stmt
1652+ assert (
1653+ "'model.sushi.waiter_as_customer_by_day' AS unique_id, 'incremental' AS materialized"
1654+ in graph_table_stmt
1655+ )
1656+ assert "'model.sushi.top_waiters' AS unique_id, 'view' AS materialized" in graph_table_stmt
1657+ assert "'model.customers.customers' AS unique_id, 'view' AS materialized" in graph_table_stmt
1658+ assert (
1659+ "'model.customers.customer_revenue_by_day' AS unique_id, 'incremental' AS materialized"
1660+ in graph_table_stmt
1661+ )
1662+ assert (
1663+ "'model.sushi.waiter_revenue_by_day.v1' AS unique_id, 'incremental' AS materialized"
1664+ in graph_table_stmt
1665+ )
1666+ assert (
1667+ "'model.sushi.waiter_revenue_by_day.v2' AS unique_id, 'incremental' AS materialized"
1668+ in graph_table_stmt
16441669 )
16451670
16461671 # Nested dbt_packages on run start / on run end
@@ -1675,6 +1700,7 @@ def test_on_run_start_end():
16751700 snapshots = sushi_context .snapshots ,
16761701 runtime_stage = RuntimeStage .AFTER_ALL ,
16771702 environment_naming_info = EnvironmentNamingInfo (name = "dev" ),
1703+ engine_adapter = sushi_context .engine_adapter ,
16781704 )
16791705
16801706 # Validate order of execution to match dbt's
0 commit comments