def test_validate_payload_not_valid_schema(): raw_data = b'{"baz": "bar"}' schema = t.Dict({t.Key('foo'): t.Atom('bar')}) with pytest.raises(JsonValidaitonError) as ctx: validate_payload(raw_data, schema) error = json.loads(ctx.value.text) assert error['error'] == 'Invalid json payload'
def test_validate_payload_not_json(): raw_data = b'foo=bar' schema = t.Dict({t.Key('foo'): t.Atom('bar')}) with pytest.raises(JsonValidaitonError) as ctx: validate_payload(raw_data, schema) error = json.loads(ctx.value.text) assert error['error'] == 'Payload is not json serialisable'
def test_validate_payload_not_valid_schema(): raw_data = b'{"baz": "bar"}' schema = t.Dict({ t.Key('foo'): t.Atom('bar') }) with pytest.raises(JsonValidaitonError) as ctx: validate_payload(raw_data, schema) error = json.loads(ctx.value.text) assert error['error'] == 'Invalid json payload'
def test_validate_payload_not_json(): raw_data = b'foo=bar' schema = t.Dict({ t.Key('foo'): t.Atom('bar') }) with pytest.raises(JsonValidaitonError) as ctx: validate_payload(raw_data, schema) error = json.loads(ctx.value.text) assert error['error'] == 'Payload is not json serialisable'
def test_validate_payload(): raw_data = b'{"foo": "bar"}' schema = t.Dict({ t.Key('foo'): t.Atom('bar') }) data = validate_payload(raw_data, schema) assert data == {'foo': 'bar'}
def test_validate_payload(): raw_data = b'{"foo": "bar"}' schema = t.Dict({t.Key('foo'): t.Atom('bar')}) data = validate_payload(raw_data, schema) assert data == {'foo': 'bar'}