def get_plugin_by_name_exists_test(self): """ Test running the get_plugin_by_name() method to find a plugin that exists """ # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.name = 'Mocked Plugin' plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run finalise_plugins() result = plugin_manager.get_plugin_by_name('Mocked Plugin') # THEN: The is_active() and finalise() methods should have been called self.assertEqual(result, mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin')
def test_get_plugin_by_name_exists(self): """ Test running the get_plugin_by_name() method to find a plugin that exists """ # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.name = 'Mocked Plugin' plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run finalise_plugins() result = plugin_manager.get_plugin_by_name('Mocked Plugin') # THEN: The is_active() and finalise() methods should have been called assert result == mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin'
def get_plugin_by_name_does_not_exist_test(self): """ Test running the get_plugin_by_name() method to find a plugin that does not exist """ # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.name = 'Mocked Plugin' plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run finalise_plugins() result = plugin_manager.get_plugin_by_name('Missing Plugin') # THEN: The is_active() and finalise() methods should have been called self.assertIsNone(result, 'The result for get_plugin_by_name should be None')
def test_get_plugin_by_name_exists(self): """ Test running the get_plugin_by_name() method to find a plugin that exists """ # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.name = 'Mocked Plugin' plugin_manager = PluginManager() Registry().register('mock_plugin', mocked_plugin) State().add_service("mock", 1, is_plugin=True, status=PluginStatus.Active) State().flush_preconditions() # WHEN: We run finalise_plugins() result = plugin_manager.get_plugin_by_name('Mocked Plugin') # THEN: The is_active() and finalise() methods should have been called assert result == mocked_plugin, 'The result for get_plugin_by_name should be the mocked plugin'