1515    PluginRouteHandlerFunctionOkResponse ,
1616    SuperTokensPlugin ,
1717)
18+ from  supertokens_python .post_init_callbacks  import  PostSTInitCallbacks 
1819from  supertokens_python .supertokens  import  SupertokensPublicConfig 
1920
2021from  tests .utils  import  outputs , reset 
4142def  setup_and_teardown ():
4243    reset ()
4344    PluginTestRecipe .reset ()
45+     PostSTInitCallbacks .reset ()
4446    yield 
4547    reset ()
4648    PluginTestRecipe .reset ()
49+     PostSTInitCallbacks .reset ()
4750
4851
4952def  recipe_factory (override_functions : bool  =  False , override_apis : bool  =  False ):
@@ -214,36 +217,41 @@ def test_overrides(
214217
215218# TODO: Figure out a way to add circular dependencies and test them 
216219@mark .parametrize ( 
217-     ("plugins" , "recipe_expectation" , "api_expectation" ), 
220+     ("plugins" , "recipe_expectation" , "api_expectation" ,  "init_expectation" ), 
218221    [ 
219222        param ( 
220223            [Plugin1 , Plugin1 ], 
221224            outputs (["plugin1" , "original" ]), 
222225            outputs (["original" ]), 
226+             outputs (["plugin1" ]), 
223227            id = "1,1 => 1" , 
224228        ), 
225229        param ( 
226230            [Plugin1 , Plugin2 ], 
227231            outputs (["plugin2" , "plugin1" , "original" ]), 
228232            outputs (["original" ]), 
233+             outputs (["plugin1" , "plugin2" ]), 
229234            id = "1,2 => 2,1" , 
230235        ), 
231236        param ( 
232237            [Plugin3Dep1 ], 
233238            outputs (["plugin3dep1" , "plugin1" , "original" ]), 
234239            outputs (["original" ]), 
240+             outputs (["plugin1" , "plugin3dep1" ]), 
235241            id = "3->1 => 3,1" , 
236242        ), 
237243        param ( 
238244            [Plugin3Dep2_1 ], 
239245            outputs (["plugin3dep2_1" , "plugin1" , "plugin2" , "original" ]), 
240246            outputs (["original" ]), 
247+             outputs (["plugin2" , "plugin1" , "plugin3dep2_1" ]), 
241248            id = "3->(2,1) => 3,2,1" , 
242249        ), 
243250        param ( 
244251            [Plugin3Dep1 , Plugin4Dep2 ], 
245252            outputs (["plugin4dep2" , "plugin2" , "plugin3dep1" , "plugin1" , "original" ]), 
246253            outputs (["original" ]), 
254+             outputs (["plugin1" , "plugin3dep1" , "plugin2" , "plugin4dep2" ]), 
247255            id = "3->1,4->2 => 4,2,3,1" , 
248256        ), 
249257        param ( 
@@ -252,20 +260,23 @@ def test_overrides(
252260                ["plugin4dep3__2_1" , "plugin3dep2_1" , "plugin1" , "plugin2" , "original" ] 
253261            ), 
254262            outputs (["original" ]), 
263+             outputs (["plugin2" , "plugin1" , "plugin3dep2_1" , "plugin4dep3__2_1" ]), 
255264            id = "4->3->(2,1) => 4,3,1,2" , 
256265        ), 
257266        param ( 
258267            [Plugin3Dep1 , Plugin4Dep1 ], 
259268            outputs (["plugin4dep1" , "plugin3dep1" , "plugin1" , "original" ]), 
260269            outputs (["original" ]), 
270+             outputs (["plugin1" , "plugin3dep1" , "plugin4dep1" ]), 
261271            id = "3->1,4->1 => 4,3,1" , 
262272        ), 
263273    ], 
264274) 
265- def  test_depdendencies (
275+ def  test_depdendencies_and_init (
266276    plugins : List [SuperTokensPlugin ],
267277    recipe_expectation : Any ,
268278    api_expectation : Any ,
279+     init_expectation : Any ,
269280):
270281    partial_init (
271282        recipe_list = [
@@ -298,8 +309,10 @@ def test_depdendencies(
298309            message = "msg" ,
299310        )
300311
312+     with  init_expectation  as  expected_stack :
313+         assert  PluginTestRecipe .init_calls  ==  expected_stack 
314+ 
301315
302- # TODO: Add tests for init, recipe config override 
303316def  test_st_config_override ():
304317    plugin  =  plugin_factory ("plugin1" , override_functions = False , override_apis = False )
305318
0 commit comments