Passed
Push — master ( 9909db...135e2c )
by Michael
03:54
created

tests.test_middleware.test_middleware()   A

Complexity

Conditions 2

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 17
rs 9.75
c 0
b 0
f 0
cc 2
nop 1
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 = '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