def testPluginsPresent(self): plugins = Plugin.get_plugins('GeoHealthCheck.probe.Probe') for plugin in plugins: plugin = Factory.create_obj(plugin) self.assertIsNotNone(plugin) # Must have run_request method self.assertIsNotNone(plugin.run_request) plugins = Plugin.get_plugins('GeoHealthCheck.check.Check') for plugin in plugins: plugin = Factory.create_obj(plugin) self.assertIsNotNone(plugin) # Must have perform method self.assertIsNotNone(plugin.perform) plugins = Plugin.get_plugins( 'GeoHealthCheck.resourceauth.ResourceAuth') for plugin in plugins: plugin = Factory.create_obj(plugin) self.assertIsNotNone(plugin) # Must have encode method self.assertIsNotNone(plugin.encode) plugins = Plugin.get_plugins('GeoHealthCheck.probe.Probe', filters=[('RESOURCE_TYPE', 'OGC:*'), ('RESOURCE_TYPE', 'OGC:WMS')]) for plugin in plugins: plugin_class = Factory.create_class(plugin) self.assertIsNotNone(plugin_class) plugin_obj = Factory.create_obj(plugin) self.assertIsNotNone( plugin_obj, 'Cannot create Plugin from string %s' + plugin) parameters = plugin_obj.PARAM_DEFS self.assertTrue( type(parameters) is dict, 'Plugin Parameters not a dict') checks = plugin_obj.CHECKS_AVAIL self.assertTrue(type(checks) is dict, 'Plugin checks not a dict') # Must have run_request method self.assertIsNotNone(plugin_obj.run_request) # Must have class var RESOURCE_TYPE='OGC:WMS' class_vars = Factory.get_class_vars(plugin) self.assertIn(class_vars['RESOURCE_TYPE'], ['OGC:WMS', 'OGC:*'])
def get_probes_avail(resource_type=None, resource=None): """ Get all available Probes with their attributes. :param resource_type: optional resource type e.g. OGC:WMS :param resource: optional Resource instance :return: """ # Assume no resource type filters = None if resource_type: filters = [('RESOURCE_TYPE', resource_type), ('RESOURCE_TYPE', '*:*')] probe_classes = Plugin.get_plugins('GeoHealthCheck.probe.Probe', filters) result = dict() for probe_class in probe_classes: probe = Factory.create_obj(probe_class) if probe: if resource: try: probe.expand_params(resource) except Exception as err: msg = 'Cannot expand plugin vars for %s err=%s' \ % (probe_class, str(err)) LOGGER.warning(msg) result[probe_class] = probe.get_plugin_vars() return result
def get_auth_defs(): """ Get available ResourceAuth definitions. :return: dict keyed by NAME with object instance values """ auth_classes = Plugin.get_plugins( baseclass='GeoHealthCheck.resourceauth.ResourceAuth') result = {} for auth_class in auth_classes: auth_obj = Factory.create_obj(auth_class) result[auth_obj.NAME] = auth_obj return result
def get_probes_avail(resource_type=None): """ Get all available Probes with their attributes. :param resource_type: optional resource type e.g. OGC:WMS :return: """ # Assume no resource type filters = None if resource_type: filters = [('RESOURCE_TYPE', resource_type), ('RESOURCE_TYPE', '*:*')] probe_classes = Plugin.get_plugins('GeoHealthCheck.probe.Probe', filters) result = dict() for probe_class in probe_classes: probe = Factory.create_obj(probe_class) result[probe_class] = probe.get_plugin_vars() return result