class PluginManagerManagementMethodsTests(unittest.TestCase): def setUp(self): self.app = Flask(__name__) self.app.config['TESTING'] = True self.plugin_manager = PluginManager() self.plugin_manager.init_app(self.app) # Call load_plugins to reload them without calling setup_plugins() self.plugin_manager.load_plugins() def test_setup_plugins(self): plugin = self.plugin_manager.plugins["test1"] self.assertFalse(plugin.setup_called) self.plugin_manager.setup_plugins() self.assertTrue(plugin.setup_called) def test_install_plugins(self): plugin = self.plugin_manager.plugins["test1"] self.assertFalse(plugin.install_called) self.plugin_manager.install_plugins() self.assertTrue(plugin.install_called) def test_uninstall_plugins(self): plugin = self.plugin_manager.plugins["test1"] self.assertFalse(plugin.uninstall_called) self.plugin_manager.uninstall_plugins() self.assertTrue(plugin.uninstall_called)
class PluginManagerOnePluginTests(unittest.TestCase): """Tests the plugin.setup(), plugin.enabled()... methods""" def setUp(self): self.app = Flask(__name__) self.app.config['TESTING'] = True self.plugin_manager = PluginManager() self.plugin_manager.init_app(self.app) def tearDown(self): # Make sure plugin "test1" is enabled plugin_path = self.plugin_manager.all_plugins["test1"].path if os.path.exists(os.path.join(plugin_path, "DISABLED")): os.remove(os.path.join(plugin_path, "DISABLED")) self.plugin_manager.load_plugins() def test_plugin_disable_and_enable(self): plugin = self.plugin_manager.plugins["test1"] self.assertFalse(plugin.disable()) plugin = self.plugin_manager.all_plugins["test1"] self.assertTrue(plugin.enable()) def test_plugin_setup(self): plugin = self.plugin_manager.plugins["test1"] plugin.setup() self.assertTrue(plugin.setup_called) def test_plugin_install(self): plugin = self.plugin_manager.plugins["test1"] plugin.install() self.assertTrue(plugin.install_called) def test_plugin_uninstall(self): plugin = self.plugin_manager.plugins["test1"] plugin.uninstall() self.assertTrue(plugin.uninstall_called)