def __init__(self): super(MonitoringCustomMetricsMiddleware, self).__init__() # checks proper dependency order as well. _check_middleware_dependencies(self, required_middleware=[ 'edx_django_utils.cache.middleware.RequestCacheMiddleware', 'edx_django_utils.monitoring.middleware.MonitoringCustomMetricsMiddleware', ])
def __init__(self, *args, **kwargs): super(MonitoringMemoryMiddleware, self).__init__(*args, **kwargs) # checks proper dependency order as well. _check_middleware_dependencies(self, required_middleware=[ 'edx_django_utils.cache.middleware.RequestCacheMiddleware', 'edx_django_utils.monitoring.middleware.MonitoringMemoryMiddleware', ])
def test_check_middleware_dependencies_complex_success(self): middleware = _TestMiddleware() _check_middleware_dependencies(middleware, required_middleware=[ 'required.2.Middleware', 'required.4.Middleware', ])
def test_check_middleware_dependencies_bad_order(self): middleware = _TestMiddleware() with self.assertRaises(AssertionError): _check_middleware_dependencies(middleware, required_middleware=[ 'required.1.Middleware', 'required.2.Middleware', ])
def __init__(self): super(TieredCacheMiddleware, self).__init__() # checks proper dependency order as well. _check_middleware_dependencies( self, required_middleware=[ 'edx_django_utils.cache.middleware.RequestCacheMiddleware', # Some Authentication Middleware also needs to be in between, # but don't want to hard-code that dependency. 'edx_django_utils.cache.middleware.TieredCacheMiddleware', ])
def __init__(self, *args, **kwargs): super(CachedCustomMonitoringMiddleware, self).__init__(*args, **kwargs) # checks proper dependency order as well. _check_middleware_dependencies(self, required_middleware=self.REQUIRED_MIDDLEWARE)
def test_check_middleware_dependencies_missing_classes(self): middleware = _TestMiddleware() with self.assertRaises(AssertionError): _check_middleware_dependencies( middleware, required_middleware=['missing.Middleware'])
def test_check_middleware_dependencies_simple__classes_success(self): middleware = _TestMiddleware() _check_middleware_dependencies( middleware, required_middleware=['required.Middleware'])