예제 #1
0
    def test_plugin_manager_instantiation(self):
        deserializer = plugypy.ConfigurationDeserializer(
            current_folder + '/plugins/config.json')
        plugins_configuraiton = deserializer.deserialize_config()

        plugin_manager = plugypy.PluginManager(current_folder + '/plugins',
                                               plugins_configuraiton, True)

        self.assertIsInstance(plugin_manager, plugypy.PluginManager)
예제 #2
0
    def test_plugins_discovery(self):
        deserializer = plugypy.ConfigurationDeserializer(
            current_folder + '/plugins/config.json')
        plugins_configuraiton = deserializer.deserialize_config()

        plugin_manager = plugypy.PluginManager(current_folder + '/plugins',
                                               plugins_configuraiton, True)

        discovered_plugins = plugin_manager.discover_plugins()
        self.assertIsInstance(discovered_plugins, list)
예제 #3
0
    def __execute_hardware_plugin(self, delay) -> bool:
        plugin_manager = plugypy.PluginManager(
            self.__plugins_directory,
            self.__configuration_file_directory,
            will_verify_ownership=True
            )

        hardware_controller_plugin = plugin_manager.import_plugin('hardware_controller')

        if hardware_controller_plugin == None:
            return False

        plugin_manager.execute_plugin(hardware_controller_plugin, (delay,), is_forced=True)
        return True
예제 #4
0
    def test_sum(self):
        deserializer = plugypy.ConfigurationDeserializer(
            current_folder + '/plugins/config.json')
        plugins_configuraiton = deserializer.deserialize_config()

        plugin_manager = plugypy.PluginManager(current_folder + '/plugins',
                                               plugins_configuraiton, True)

        discovered_plugins = plugin_manager.discover_plugins()
        imported_plugins = plugin_manager.import_plugins(discovered_plugins)

        result = plugin_manager.execute_plugin_function(
            imported_plugins[2],
            function_name='sum_arguments',
            args=arguments[2])

        self.assertEqual(result, sum(arguments[2]))
예제 #5
0
    def test_print_message(self):
        deserializer = plugypy.ConfigurationDeserializer(
            current_folder + '/plugins/config.json')
        plugins_configuraiton = deserializer.deserialize_config()

        plugin_manager = plugypy.PluginManager(current_folder + '/plugins',
                                               plugins_configuraiton, True)

        discovered_plugins = plugin_manager.discover_plugins()
        imported_plugins = plugin_manager.import_plugins(discovered_plugins)

        result = plugin_manager.execute_plugin_function(
            imported_plugins[1],
            function_name='print_message',
            args=arguments[1])

        self.assertIsNone(result)
예제 #6
0
    def __run_external_tests(self) -> bool:
        plugin_arguments_tuple = (self.__device, self.__device_handle)

        plugin_manager = plugypy.PluginManager(
            self.__plugins_directory, 
            self.__configuration_file_directory, 
            will_verify_ownership=True
            )
        
        plugins_list = plugin_manager.import_plugins()

        for plugin in plugins_list:
            result = plugin_manager.execute_plugin(plugin, plugin_arguments_tuple)

            if result == False:
                print('Custom test: {} was not passed.'.format(plugin['name']))
                return False
        return True