Exemple #1
0
def test_path_change_when_load_library(simple_plugin_dll, mocker):
    mocker.patch("hookman.hookman_utils.change_path_env")
    from hookman.hookman_utils import change_path_env, load_shared_lib

    with load_shared_lib(str(simple_plugin_dll)):
        pass
    change_path_env.assert_called_once()
Exemple #2
0
 def _get_hooks_implemented(self) -> List[str]:
     """
     Return a list of which hooks from "hooks_available" the shared library implements
     """
     with load_shared_lib(str(self.shared_lib_path)) as plugin_dll:
         hooks_implemented = [
             hook_name
             for hook_name, full_hook_name in self.hooks_available.items()
             if PluginInfo.is_implemented_on_plugin(plugin_dll,
                                                    full_hook_name)
         ]
     return hooks_implemented
Exemple #3
0
 def _get_plugin_id_from_dll(self, plugin_id_from_plugin_yaml: str) -> str:
     self._check_if_shared_lib_exists()
     with load_shared_lib(str(self.shared_lib_path)) as plugin_dll:
         plugin_dll.get_plugin_id.restype = ctypes.c_char_p
         plugin_id_from_shared_lib = plugin_dll.get_plugin_id().decode(
             "utf-8")
         if plugin_id_from_shared_lib != plugin_id_from_plugin_yaml:
             msg = (
                 f'Error, the plugin_id inside plugin.yaml is "{plugin_id_from_plugin_yaml}" '
                 f"while the plugin_id inside the {self.shared_lib_name} is {plugin_id_from_shared_lib}"
             )
             raise RuntimeError(msg)
         return plugin_id_from_shared_lib