示例#1
0
def main():
    """Initialize and start Meguca or clean-up and stop it."""

    print('Starting Meguca')
    logger.info('Initialize Meguca')

    try:
        general_config = utils.load_config(info.GENERAL_CONFIG_PATH)
        logger.info('Loaded general configuration')
    except FileNotFoundError:
        logger.critical('Could not find general configuration file!')
        raise exceptions.ConfigError(
            'Could not find general configuration file!')

    plg_manager = plugin.PlgManager(info.PLUGIN_DIR_PATH, info.PLUGIN_DESC_EXT)
    plg_config = plg_manager.load_plugins()

    meguca = Meguca(plg_manager, general_config, plg_config)
    meguca.prepare()
    logger.info('Prepared everything')

    meguca.run()

    try:
        while True:
            pass
    except (KeyboardInterrupt, SystemExit):
        meguca.shutdown()
示例#2
0
    def test_load_plugins_with_existing_plugins(self, activatePluginByName,
                                                collectPlugins, load_config,
                                                mock_plg):
        with mock.patch('yapsy.PluginManager.PluginManager.getAllPlugins'
                        ) as getAllPlugins:
            getAllPlugins.return_value = [mock_plg()]

            plugins_ins = plugin.PlgManager('', '')

            assert plugins_ins.load_plugins() == {'Test': 'Test'}
示例#3
0
    def test_load_plugins_with_no_plugins_found(self, activatePluginByName,
                                                collectPlugins, load_config,
                                                mock_plg):
        with mock.patch('yapsy.PluginManager.PluginManager.getAllPlugins'
                        ) as getAllPlugins:
            getAllPlugins.return_value = []

            plugins_ins = plugin.PlgManager('', '')

            with pytest.raises(exceptions.PluginManagerError):
                plugins_ins.load_plugins()
示例#4
0
    def test_dry_run_meguca_real_plugins_and_config(self):
        general_config = utils.load_config('tests/resources/general_config_dryrun.toml')
        plg_manager = plugin.PlgManager('tests/resources/plugins', 'plugin')
        plugin_config = plg_manager.load_plugins()

        meguca_ins = meguca.Meguca(plg_manager, general_config, plugin_config)

        meguca_ins.prepare()
        meguca_ins.run()

        assert meguca_ins.data == {'MadokaDry': 'TestVal', 'SayakaPrep': 'TestVal',
                                   'SayakaDry': 'TestVal'}
示例#5
0
    def test_load_plugins_with_plugin_not_have_id(self, activatePluginByName,
                                                  collectPlugins, load_config,
                                                  mock_plg):
        with mock.patch('yapsy.PluginManager.PluginManager.getAllPlugins'
                        ) as getAllPlugins:
            mock_plg = mock_plg()
            mock_plg.details['Core'].pop('Id')
            getAllPlugins.return_value = [mock_plg]

            plugins_ins = plugin.PlgManager('', '')

            with pytest.raises(exceptions.PluginManagerError):
                plugins_ins.load_plugins()
示例#6
0
    def test_run_meguca_with_real_plugins_and_config(self):
        general_config = utils.load_config('tests/resources/general_config.toml')
        plg_manager = plugin.PlgManager('tests/resources/plugins', 'plugin')
        plugin_config = plg_manager.load_plugins()

        meguca_ins = meguca.Meguca(plg_manager, general_config, plugin_config)

        meguca_ins.prepare()
        meguca_ins.run()

        time.sleep(8)

        assert meguca_ins.data == {'Homura': 'TestVal', 'Madoka': 'TestVal',
                                   'Sayaka': 'TestVal', 'SayakaPrep': 'TestVal'}
示例#7
0
    def test_get_all_plugins(self, getAllPlugins, activatePluginByName,
                             collectPlugins, load_config):
        plugins_ins = plugin.PlgManager('', '')

        assert plugins_ins.get_all_plugins() == 'Test'
示例#8
0
    def test_get_plugins_with_no_plugins(self, getPluginsOfCategory,
                                         activatePluginByName, collectPlugins,
                                         load_config):
        plugins_ins = plugin.PlgManager('', '')

        assert plugins_ins.get_plugins('Test') == []