@@ -3199,7 +3199,9 @@ def test_grants_through_plan_apply(sushi_context, mocker):
31993199
32003200 sushi_context .plan ("dev" , no_prompts = True , auto_apply = True )
32013201
3202- assert sync_grants_mock .call_count == 2
3202+ # When planning for dev env w/ metadata only changes,
3203+ # only virtual layer is updated, so no physical grants are applied
3204+ assert sync_grants_mock .call_count == 1
32033205 assert all (
32043206 call [0 ][1 ] == {"select" : ["analyst" , "reporter" ]}
32053207 for call in sync_grants_mock .call_args_list
@@ -3212,15 +3214,19 @@ def test_grants_through_plan_apply(sushi_context, mocker):
32123214 update = {
32133215 "query" : parse_one (model .query .sql () + " LIMIT 1000" ),
32143216 "grants" : new_grants ,
3217+ # force model update, hence new physical table creation
32153218 "stamp" : "update model and grants" ,
32163219 }
32173220 )
32183221 sushi_context .upsert_model (model_updated )
3219-
32203222 sushi_context .plan ("dev" , no_prompts = True , auto_apply = True )
32213223
3222- # Applies grants 3 times:
3223- # 2 x physical (duplicated): create, promote (will diff but won't apply since it's the same grants)
3224- # 1 x virtual
3225- assert sync_grants_mock .call_count == 3
3224+ # Applies grants 2 times: 1 x physical, 1 x virtual
3225+ assert sync_grants_mock .call_count == 2
32263226 assert all (call [0 ][1 ] == new_grants for call in sync_grants_mock .call_args_list )
3227+
3228+ sync_grants_mock .reset_mock ()
3229+
3230+ # plan for prod
3231+ sushi_context .plan (no_prompts = True , auto_apply = True )
3232+ assert sync_grants_mock .call_count == 2
0 commit comments