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