示例#1
0
def test_parse_without_validation():
    parse(
        '{"jsonrpc": "2.0", "result": "foo", "id": 1}',
        batch=False,
        validate_against_schema=False,
    )
示例#2
0
def test_parse_batch():
    data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]', batch=True)
    assert data[0].result == "foo"
示例#3
0
def test_parse_invalid_json():
    with pytest.raises(JSONDecodeError):
        parse("{dodgy}", batch=False)
示例#4
0
def test_parse_invalid_jsonrpc():
    with pytest.raises(ValidationError):
        parse('{"json": "2.0"}', batch=False)
示例#5
0
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
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
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
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
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
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"}')