コード例 #1
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_without_validation():
    parse(
        '{"jsonrpc": "2.0", "result": "foo", "id": 1}',
        batch=False,
        validate_against_schema=False,
    )
コード例 #2
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_batch():
    data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]', batch=True)
    assert data[0].result == "foo"
コード例 #3
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_invalid_json():
    with pytest.raises(JSONDecodeError):
        parse("{dodgy}", batch=False)
コード例 #4
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_invalid_jsonrpc():
    with pytest.raises(ValidationError):
        parse('{"json": "2.0"}', batch=False)
コード例 #5
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_none_batch():
    assert parse(None, batch=True) == []
コード例 #6
0
 def test_without_validation(self, *_):
     parse(
         '{"jsonrpc": "2.0", "result": "foo", "id": 1}',
         validate_against_schema=False,
     )
コード例 #7
0
 def test_invalid_json(self, *_):
     with pytest.raises(exceptions.ParseResponseError):
         parse("{dodgy}")
コード例 #8
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_empty_string_batch():
    assert parse("", batch=True) == []
コード例 #9
0
 def test_empty_string(self, *_):
     assert parse("") is None
コード例 #10
0
 def test(self, *_):
     parse('{"jsonrpc": "2.0", "result": "foo", "id": 1}')
コード例 #11
0
 def test_none(self, *_):
     assert parse(None) is None
コード例 #12
0
 def test_batch_ignores_notifications(self, *_):
     data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]')
     assert len(data) == 1
コード例 #13
0
 def test_batch(self, *_):
     data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]')
     assert data[0].result == "foo"
コード例 #14
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_batch_ignores_notifications():
    data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]', batch=True)
    assert len(data) == 1
コード例 #15
0
 def test_empty_string_batch(self, *_):
     assert parse("", batch=True) == []
コード例 #16
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_empty_string_single():
    assert parse("", batch=False).result is None
コード例 #17
0
 def test_none_single(self, *_):
     assert parse(None, batch=False).result is None
コード例 #18
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse_none_single():
    assert parse(None, batch=False).result is None
コード例 #19
0
 def test_none_batch(self, *_):
     assert parse(None, batch=True) == []
コード例 #20
0
ファイル: test_parse.py プロジェクト: zhwei820/jsonrpcclient
def test_parse():
    parse('{"jsonrpc": "2.0", "result": "foo", "id": 1}', batch=False)
コード例 #21
0
 def test_invalid_jsonrpc(self, *_):
     with pytest.raises(ValidationError):
         parse('{"json": "2.0"}')