예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 def make_convetion(self):
     middleware.execute(settings.MIDDLEWARES, self)