How to use the djet.testcases.MiddlewareType function in djet

To help you get started, we’ve selected a few djet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sunscrapers / djet / djet / testcases.py View on Github external
def _load_new_middleware(self):
        from django.core.handlers.exception import convert_exception_to_response
        handler = convert_exception_to_response(self._get_response)
        middleware_classes = reversed(self.middleware or [])
        for mw_class in middleware_classes:
            mw_class, mw_types = self._unpack_middleware(mw_class)
            mw_instance = mw_class(handler)

            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_VIEW):
                self._view_middleware.insert(0, mw_instance.process_view)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_TEMPLATE_RESPONSE):
                self._template_response_middleware.append(mw_instance.process_template_response)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_EXCEPTION):
                self._exception_middleware.append(mw_instance.process_exception)

            handler = convert_exception_to_response(mw_instance)
        self._middleware_chain = handler
github sunscrapers / djet / djet / testcases.py View on Github external
def _load_new_middleware(self):
        from django.core.handlers.exception import convert_exception_to_response
        handler = convert_exception_to_response(self._get_response)
        middleware_classes = reversed(self.middleware or [])
        for mw_class in middleware_classes:
            mw_class, mw_types = self._unpack_middleware(mw_class)
            mw_instance = mw_class(handler)

            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_VIEW):
                self._view_middleware.insert(0, mw_instance.process_view)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_TEMPLATE_RESPONSE):
                self._template_response_middleware.append(mw_instance.process_template_response)
            if self._should_add_middleware(mw_instance, mw_types, MiddlewareType.PROCESS_EXCEPTION):
                self._exception_middleware.append(mw_instance.process_exception)

            handler = convert_exception_to_response(mw_instance)
        self._middleware_chain = handler