| Total Complexity | 2 | 
| Total Lines | 22 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | import aiohttp_rpc  | 
            ||
| 2 | from tests import utils  | 
            ||
| 3 | |||
| 4 | |||
| 5 | async def test_middleware(aiohttp_client):  | 
            ||
| 6 | def method():  | 
            ||
| 7 | return 'ok'  | 
            ||
| 8 | |||
| 9 | async def test_middleware(request, handler):  | 
            ||
| 10 | request.method_name = 'method'  | 
            ||
| 11 | response = await handler(request)  | 
            ||
| 12 | response.result += '!'  | 
            ||
| 13 | return response  | 
            ||
| 14 | |||
| 15 | rpc_server = aiohttp_rpc.JsonRpcServer(middlewares=(test_middleware,))  | 
            ||
| 16 | rpc_server.add_method(method)  | 
            ||
| 17 | |||
| 18 | client = await utils.make_client(aiohttp_client, rpc_server)  | 
            ||
| 19 | |||
| 20 |     async with aiohttp_rpc.JsonRpcClient('/rpc', session=client) as rpc: | 
            ||
| 21 |         assert await rpc.call('my_method') == 'ok!' | 
            ||
| 22 |