tests.utils.make_ws_client()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
import aiohttp
2
from aiohttp import web
3
4
import aiohttp_rpc
5
6
7
async def make_client(aiohttp_client, rpc_server: aiohttp_rpc.JsonRpcServer) -> aiohttp.ClientSession:
8
    app = web.Application()
9
    app.router.add_post('/rpc', rpc_server.handle_http_request)
10
    return await aiohttp_client(app)
11
12
13
async def make_ws_client(aiohttp_client, rpc_server: aiohttp_rpc.WsJsonRpcServer) -> aiohttp.ClientSession:
14
    app = web.Application()
15
    app.router.add_get('/rpc', rpc_server.handle_http_request)
16
    app.on_shutdown.append(rpc_server.on_shutdown)
17
    return await aiohttp_client(app)
18