def test_parse_without_validation(): parse( '{"jsonrpc": "2.0", "result": "foo", "id": 1}', batch=False, validate_against_schema=False, )
def test_parse_batch(): data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]', batch=True) assert data[0].result == "foo"
def test_parse_invalid_json(): with pytest.raises(JSONDecodeError): parse("{dodgy}", batch=False)
def test_parse_invalid_jsonrpc(): with pytest.raises(ValidationError): parse('{"json": "2.0"}', batch=False)
def test_parse_none_batch(): assert parse(None, batch=True) == []
def test_without_validation(self, *_): parse( '{"jsonrpc": "2.0", "result": "foo", "id": 1}', validate_against_schema=False, )
def test_invalid_json(self, *_): with pytest.raises(exceptions.ParseResponseError): parse("{dodgy}")
def test_parse_empty_string_batch(): assert parse("", batch=True) == []
def test_empty_string(self, *_): assert parse("") is None
def test(self, *_): parse('{"jsonrpc": "2.0", "result": "foo", "id": 1}')
def test_none(self, *_): assert parse(None) is None
def test_batch_ignores_notifications(self, *_): data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]') assert len(data) == 1
def test_batch(self, *_): data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]') assert data[0].result == "foo"
def test_parse_batch_ignores_notifications(): data = parse('[{"jsonrpc": "2.0", "result": "foo", "id": 1}]', batch=True) assert len(data) == 1
def test_empty_string_batch(self, *_): assert parse("", batch=True) == []
def test_parse_empty_string_single(): assert parse("", batch=False).result is None
def test_none_single(self, *_): assert parse(None, batch=False).result is None
def test_parse_none_single(): assert parse(None, batch=False).result is None
def test_none_batch(self, *_): assert parse(None, batch=True) == []
def test_parse(): parse('{"jsonrpc": "2.0", "result": "foo", "id": 1}', batch=False)
def test_invalid_jsonrpc(self, *_): with pytest.raises(ValidationError): parse('{"json": "2.0"}')