def test_execute(self): mid_flags = [False, False] def middleware_1(next_process, handler, dependencies, **kwargs): mid_flags[0] = True dependencies['_foo'] = 'foo' next_process(dependencies, kwarg_1='bar1') def middleware_2(next_process, handler, dependencies, **kwargs): mid_flags[1] = True self.assertEqual('foo', dependencies['_foo']) self.assertDictEqual({'kwarg_1': 'bar1'}, kwargs) next_process(dependencies, **kwargs) middleware.execute([middleware_1, middleware_2], None) self.assertListEqual([True, True], mid_flags)
def make_convetion(self): middleware.execute(settings.MIDDLEWARES, self)