def test_find_interop_namespace(testcase, deflt, nss, exp_ns): # pylint: disable=unused-argument """ Test the method """ conn = FakedWBEMConnection(default_namespace=deflt) if nss: if isinstance(nss, six.string_types): nss = [nss] for name in nss: conn.add_namespace(name) rtnd_ns = conn.find_interop_namespace() assert rtnd_ns == exp_ns
def create_registered_conn(providers): """ Create and return a FakedWBEMConnection object that has the specified providers registered. providers: Providers to be registered. providers are specified as tuple(prov_class, cim_class, namespace): - prov_class: Python class of provider - cim_class: Name of CIM class for the provider - namespace: CIM namespace for the provider """ # Build a FakedWBEMConnection that has the required namespaces, classes # and registered providers in its provider registry. conn = FakedWBEMConnection() for item in providers: prov_class, cim_class, namespace = item # Make sure the namespace exists in the CIM repository if namespace not in conn.namespaces: conn.add_namespace(namespace) # Make sure the CIM class exists in the CIM repository class_store = conn.cimrepository.get_class_store(namespace) if not class_store.object_exists(cim_class): # An empty class is sufficient for this purpose: class_obj = CIMClass(cim_class) conn.add_cimobjects(class_obj, namespace=namespace) # Create the provider object, setting up its provider classes prov_class.provider_classnames = cim_class prov_obj = prov_class(conn.cimrepository) # Register the provider conn.register_provider(prov_obj, namespaces=namespace) return conn