tests.test_middleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 16
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_middleware() 0 17 2
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