@@ 99-115 (lines=17) @@ | ||
96 | assert result[0] is None |
|
97 | ||
98 | ||
99 | async def test_rpc_call_of_non_existent_method(aiohttp_client): |
|
100 | """ |
|
101 | --> {"jsonrpc": "2.0", "method": "foobar", "id": "1"} |
|
102 | <-- {"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}, "id": "1"} |
|
103 | """ |
|
104 | ||
105 | rpc_server = aiohttp_rpc.JsonRpcServer() |
|
106 | ||
107 | client = await utils.make_client(aiohttp_client, rpc_server) |
|
108 | ||
109 | async with aiohttp_rpc.JsonRpcClient('/rpc', session=client) as rpc: |
|
110 | with pytest.raises(errors.MethodNotFound): |
|
111 | assert await rpc.call('foobar', subtrahend=23, minuend=42) |
|
112 | ||
113 | result = await rpc.send_json({'jsonrpc': '2.0', 'method': 'foobar', 'id': '1'}) |
|
114 | assert result[0] == { |
|
115 | 'jsonrpc': '2.0', 'error': {'code': -32601, 'message': errors.MethodNotFound.message}, 'id': '1', |
|
116 | } |
|
117 | ||
118 |
@@ 100-115 (lines=16) @@ | ||
97 | assert result[0] is None |
|
98 | ||
99 | ||
100 | async def test_rpc_call_of_non_existent_method(aiohttp_client): |
|
101 | """ |
|
102 | --> {"jsonrpc": "2.0", "method": "foobar", "id": "1"} |
|
103 | <-- {"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method not found"}, "id": "1"} |
|
104 | """ |
|
105 | ||
106 | rpc_server = aiohttp_rpc.WsJsonRpcServer() |
|
107 | client = await utils.make_ws_client(aiohttp_client, rpc_server) |
|
108 | ||
109 | async with aiohttp_rpc.WsJsonRpcClient('/rpc', session=client) as rpc: |
|
110 | with pytest.raises(errors.MethodNotFound): |
|
111 | assert await rpc.call('foobar', subtrahend=23, minuend=42) |
|
112 | ||
113 | result = await rpc.send_json({'jsonrpc': '2.0', 'method': 'foobar', 'id': '1'}) |
|
114 | assert result[0] == { |
|
115 | 'jsonrpc': '2.0', 'error': {'code': -32601, 'message': errors.MethodNotFound.message}, 'id': '1', |
|
116 | } |
|
117 | ||
118 |