@@ -997,32 +997,23 @@ def test_model_grants_engine_specific_bigquery() -> None:
997997 assert grants_config ["select" ] == ["analyst@company.com" ]
998998
999999
1000- def test_ephemeral_model_with_global_grants (create_empty_project ):
1001- dbt_project_dir , dbt_model_dir = create_empty_project ()
1002-
1003- yaml = YAML ()
1004- dbt_project_config = {
1005- "name" : "test_project" ,
1006- "version" : "1.0.0" ,
1007- "config-version" : 2 ,
1008- "profile" : "test" ,
1009- "model-paths" : ["models" ],
1010- "models" : {"test_project" : {"grants" : {"select" : ["reporter" , "analyst" ]}}},
1011- }
1012- dbt_project_file = dbt_project_dir / "dbt_project.yml"
1013- with open (dbt_project_file , "w" , encoding = "utf-8" ) as f :
1014- yaml .dump (dbt_project_config , f )
1000+ def test_ephemeral_model_ignores_grants () -> None :
1001+ """Test that ephemeral models ignore grants configuration."""
1002+ model_config = ModelConfig (
1003+ name = "ephemeral_model" ,
1004+ sql = "SELECT 1 as id" ,
1005+ materialized = "ephemeral" ,
1006+ grants = {"select" : ["reporter" , "analyst" ]},
1007+ path = Path ("ephemeral_model.sql" ),
1008+ )
10151009
1016- ephemeral_model_sql = """
1017- {{ config(materialized='ephemeral') }}
1018- SELECT 1 as id
1019- """
1020- ephemeral_model_file = dbt_model_dir / "ephemeral_model.sql"
1021- with open (ephemeral_model_file , "w" , encoding = "utf-8" ) as f :
1022- f .write (ephemeral_model_sql )
1010+ context = DbtContext ()
1011+ context .project_name = "test_project"
1012+ context .target = DuckDbConfig (name = "target" , schema = "test_schema" )
10231013
1024- context = Context (paths = dbt_project_dir )
1025- model = context .get_model ('"local"."main"."ephemeral_model"' )
1014+ sqlmesh_model = model_config .to_sqlmesh (
1015+ context , virtual_environment_mode = VirtualEnvironmentMode .FULL
1016+ )
10261017
1027- assert model .kind .is_embedded
1028- assert model .grants is None # grants config is skipped for ephemeral / embedded models
1018+ assert sqlmesh_model .kind .is_embedded
1019+ assert sqlmesh_model .grants is None # grants config is skipped for ephemeral / embedded models
0 commit comments