@@ -105,7 +105,7 @@ def test_getting_all_plugins():
105105 j .load_manifests ()
106106 j .load_plugins ()
107107 for item in j .get_all_plugins ():
108- if item ["manifest" ]["name" ] == "Missing Dependency Test" :
108+ if item ["manifest" ]["name" ] in [ "Missing Dependency Test" , "Invalid Baseclass Test" , "Error Test" ] :
109109 assert isinstance (item ["manifest" ], dict )
110110 assert not isinstance (item ["plugin" ], jigsaw .JigsawPlugin )
111111 else :
@@ -132,3 +132,38 @@ def test_reload_specific_plugin():
132132 j .load_manifests ()
133133 j .load_plugin (j .get_manifest ("Basic Test" ))
134134 j .reload_plugin ("Basic Test" )
135+
136+
137+ def test_load_invalid_plugin_manifest ():
138+ j = jigsaw .PluginLoader (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" )))
139+ j .load_manifest (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" , "InvalidManifestTest" )))
140+ assert j .get_manifest ("Invalid Manifest Test" ) is None
141+
142+
143+ def test_loading_plugin_already_loaded ():
144+ j = jigsaw .PluginLoader (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" )))
145+ j .load_manifests ()
146+ j .load_plugin (j .get_manifest ("Basic Test" ))
147+ j .load_plugin (j .get_manifest ("Basic Test" ))
148+
149+
150+ def test_invalid_baseclass ():
151+ j = jigsaw .PluginLoader (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" )))
152+ j .load_manifests ()
153+ j .load_plugin (j .get_manifest ("Invalid Baseclass Test" ))
154+ assert not j .get_plugin_loaded ("Invalid Baseclass Test" )
155+
156+
157+ def test_error_on_plugin_load ():
158+ j = jigsaw .PluginLoader (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" )))
159+ j .load_manifests ()
160+ j .load_plugin (j .get_manifest ("Error Test" ))
161+ assert os .path .isfile (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" , "ErrorTest" , "error.log" )))
162+
163+
164+ def test_oserror_on_load_plugin_manifest ():
165+ j = jigsaw .PluginLoader (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" )))
166+ os .mkdir (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" , "OSErrorTest" , "plugin.json" )))
167+ j .load_manifest (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" , "OSErrorTest" )))
168+ os .rmdir (os .path .abspath (os .path .join (os .path .abspath (__file__ ), ".." , "plugins" , "OSErrorTest" , "plugin.json" )))
169+ assert j .get_manifest ("OS Error Test" ) is None
0 commit comments