def test_fetch_c_hybrid_plugins_installed(self): info = { "version": "1.6.0", "name": "FlirAX8", "config": { "asset": { "description": "Default asset name", "default": "flir", "displayName": "Asset Name", "type": "string" }, "plugin": { "description": "A Modbus connected Flir AX8 infrared camera", "default": "FlirAX8", "readonly": "true", "type": "string" } } } with patch.object(utils, "find_c_plugin_libs", return_value=[("FlirAX8", "json") ]) as patch_plugin_lib: with patch.object(common, "load_and_fetch_c_hybrid_plugin_info", return_value=info) as patch_hybrid_plugin_info: PluginDiscovery.fetch_c_plugins_installed('south', True) patch_hybrid_plugin_info.assert_called_once_with( info['name'], True) patch_plugin_lib.assert_called_once_with('south')
def test_fetch_c_plugins_installed(self, info, dir_name): with patch.object(utils, "find_c_plugin_libs", return_value=[info['name']]) as patch_plugin_lib: with patch.object(utils, "get_plugin_info", return_value=info) as patch_plugin_info: PluginDiscovery.fetch_c_plugins_installed(dir_name, True) patch_plugin_info.assert_called_once_with(info['name'], dir=dir_name) patch_plugin_lib.assert_called_once_with(dir_name)
def test_bad_fetch_c_north_plugin_installed(self, info, exc_count): with patch.object(_logger, "exception") as patch_log_exc: with patch.object(utils, "find_c_plugin_libs", return_value=["PI_Server"]) as patch_plugin_lib: with patch.object(utils, "get_plugin_info", return_value=info) as patch_plugin_info: PluginDiscovery.fetch_c_plugins_installed("north", False) patch_plugin_info.assert_called_once_with('PI_Server', dir='north') patch_plugin_lib.assert_called_once_with('north') assert exc_count == patch_log_exc.call_count
def test_bad_fetch_c_south_plugin_installed(self, info, exc_count): with patch.object(_logger, "exception") as patch_log_exc: with patch.object(utils, "find_c_plugin_libs", return_value=[("Random", "binary") ]) as patch_plugin_lib: with patch.object(utils, "get_plugin_info", return_value=info) as patch_plugin_info: PluginDiscovery.fetch_c_plugins_installed("south", False) patch_plugin_info.assert_called_once_with('Random', dir='south') patch_plugin_lib.assert_called_once_with('south') assert exc_count == patch_log_exc.call_count
def test_deprecated_c_plugins_installed(self, info, dir_name): info['flag'] = api_utils.DEPRECATED_BIT_MASK_VALUE with patch.object(_logger, "warning") as patch_log_warn: with patch.object(utils, "find_c_plugin_libs", return_value=[(info['name'], "binary") ]) as patch_plugin_lib: with patch.object(utils, "get_plugin_info", return_value=info) as patch_plugin_info: PluginDiscovery.fetch_c_plugins_installed(dir_name, True) patch_plugin_info.assert_called_once_with(info['name'], dir=dir_name) patch_plugin_lib.assert_called_once_with(dir_name) assert 1 == patch_log_warn.call_count args, kwargs = patch_log_warn.call_args assert '"{}" plugin is deprecated'.format(info['name']) == args[0]