def test_cache_checks_type():
    cache = InMemoryCache()

    async def foo():
        pass

    with pytest.raises(TypeError):
        cache.add('x', foo())
def test_cache_checks_type():
    cache = InMemoryCache()

    async def foo():
        pass

    with pytest.raises(TypeError):
        cache.add("x", foo())
    def load_class_variables(cls, app_configs):
        """load_class_variables loads in the app_configs dict
        and assigned each value as a class variable.
        After loading, a zeep SOAP Client is created with our credentials

        :param app_configs: a dictionary containing key-value pairs used for
        setting up a client with Symantec DLP.
        :type app_configs: dict
        """
        cls.is_connected = False # Set is_connected to false initially
        
        validate_fields(['sdlp_host', 'sdlp_wsdl', 'sdlp_username', 'sdlp_password', 'sdlp_savedreportid', 'sdlp_incident_endpoint'], kwargs=app_configs)

        LOG.debug("Validated Mandatory app.configs for DLPSoapClient")

        cls.host = app_configs.get('sdlp_host')
        cls.wsdl = app_configs.get('sdlp_wsdl')
        # Gather the DLP User Name
        cls.dlp_username = app_configs.get('sdlp_username')
        # Gather the DLP User Password
        cls.dlp_password = app_configs.get('sdlp_password')

        # Gather the DLP Cert
        cls.dlp_cert = app_configs.get('sdlp_cafile', False)

        # Gather the DLP Saved Report ID
        cls.dlp_saved_report_id = app_configs.get('sdlp_savedreportid')

        # Gather the DLP Incident Endpoint
        cls.sdlp_incident_endpoint = app_configs.get('sdlp_incident_endpoint')

        cls.session = Session()
        # Use DLP Cert if provided or if None, set verify to false
        cls.session.verify = cls.dlp_cert
        cls.session.auth = SymantecAuth(cls.dlp_username, cls.dlp_password, cls.host)


        mimefile_abs_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            os.path.pardir, "data", "xmlmime.xml")
        # If the Xmlmime file was provided
        if os.path.isfile(mimefile_abs_path):
            LOG.info("A Local XML file was found in the data directory, %s \n Loading this into the cache", mimefile_abs_path)
            # Open it and add it to a Cache
            with open(mimefile_abs_path, mode="rb") as f:
                filecontent = f.read()
                dlp_cache = InMemoryCache()
                dlp_cache.add("http://www.w3.org/2005/05/xmlmime", filecontent)
                dlp_cache.add("https://www.w3.org/2005/05/xmlmime", filecontent)
            # Setup Transport with credentials and the cached mimefile
            cls.transport = zeep.Transport(session=cls.session, cache=dlp_cache)
        else:
            # Setup Transport with our credentials
            cls.transport = zeep.Transport(session=cls.session)

        try: # Try to create a soap_client from the wsdl and transport
            cls.soap_client = zeep.Client(wsdl=cls.wsdl, transport=cls.transport)
        except Exception as caught_exc: # We got an error when setting up a client, catch and release the error in logs so circuits doesn't stop
            # Put the traceback into DEBUG
            LOG.debug(traceback.format_exc())
            # Log the Connection error to the user
            LOG.error(u"Problem: %s", repr(caught_exc))
            LOG.error(u"[Symantec DLP] Encountered an exception when setting up the SOAP Client")
            
        else: # No connection error, client is setup with the URL. Allow the poller to be setup
            cls.is_connected = True
        cls.class_vars_loaded = True