@@ -135,6 +135,16 @@ def frontend_metadata(self):
135135 )
136136
137137
138+ class FakePluginLoader (base_plugin .TBLoader ):
139+ """Pass-through loader for FakePlugin with arbitrary arguments."""
140+
141+ def __init__ (self , ** kwargs ):
142+ self ._kwargs = kwargs
143+
144+ def load (self , context ):
145+ return FakePlugin (context , ** self ._kwargs )
146+
147+
138148class ApplicationTest (tb_test .TestCase ):
139149 def setUp (self ):
140150 plugins = [
@@ -357,6 +367,26 @@ def testSlashlessRoute(self):
357367 application .TensorBoardWSGI ([self ._make_plugin ('runaway' )])
358368
359369
370+ class MakePluginLoaderTest (tb_test .TestCase ):
371+
372+ def testMakePluginLoader_pluginClass (self ):
373+ loader = application .make_plugin_loader (FakePlugin )
374+ self .assertIsInstance (loader , base_plugin .BasicLoader )
375+ self .assertIs (loader .plugin_class , FakePlugin )
376+
377+ def testMakePluginLoader_pluginLoaderClass (self ):
378+ loader = application .make_plugin_loader (FakePluginLoader )
379+ self .assertIsInstance (loader , FakePluginLoader )
380+
381+ def testMakePluginLoader_pluginLoader (self ):
382+ loader = FakePluginLoader ()
383+ self .assertIs (loader , application .make_plugin_loader (loader ))
384+
385+ def testMakePluginLoader_invalidType (self ):
386+ with six .assertRaisesRegex (self , TypeError , 'FakePlugin' ):
387+ application .make_plugin_loader (FakePlugin ())
388+
389+
360390class GetEventFileActiveFilterTest (tb_test .TestCase ):
361391
362392 def testDisabled (self ):
@@ -519,23 +549,21 @@ def setUp(self):
519549 self .app = application .standard_tensorboard_wsgi (
520550 FakeFlags (logdir = self .get_temp_dir ()),
521551 [
522- base_plugin .BasicLoader (functools .partial (
523- FakePlugin ,
524- plugin_name = 'foo' ,
525- is_active_value = True ,
526- routes_mapping = {'/foo_route' : self ._foo_handler },
527- construction_callback = self ._construction_callback )),
528- base_plugin .BasicLoader (functools .partial (
529- FakePlugin ,
530- plugin_name = 'bar' ,
531- is_active_value = True ,
532- routes_mapping = {
533- '/bar_route' : self ._bar_handler ,
534- '/wildcard/*' : self ._wildcard_handler ,
535- '/wildcard/special/*' : self ._wildcard_special_handler ,
536- '/wildcard/special/exact' : self ._foo_handler ,
537- },
538- construction_callback = self ._construction_callback )),
552+ FakePluginLoader (
553+ plugin_name = 'foo' ,
554+ is_active_value = True ,
555+ routes_mapping = {'/foo_route' : self ._foo_handler },
556+ construction_callback = self ._construction_callback ),
557+ FakePluginLoader (
558+ plugin_name = 'bar' ,
559+ is_active_value = True ,
560+ routes_mapping = {
561+ '/bar_route' : self ._bar_handler ,
562+ '/wildcard/*' : self ._wildcard_handler ,
563+ '/wildcard/special/*' : self ._wildcard_special_handler ,
564+ '/wildcard/special/exact' : self ._foo_handler ,
565+ },
566+ construction_callback = self ._construction_callback ),
539567 ],
540568 dummy_assets_zip_provider )
541569
0 commit comments