Skip to content

Commit

Permalink
Merge pull request #103 from acmiyaguchi/bump-rapidjson
Browse files Browse the repository at this point in the history
Track rapidjson@67a17cf for bugfixes related to JSONSchema validation
  • Loading branch information
lelit committed Jun 6, 2018
2 parents 60147e1 + 6fa94cc commit 639b892
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rapidjson
Submodule rapidjson updated 112 files
23 changes: 23 additions & 0 deletions tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ def test_invalid(schema, json, details):
with pytest.raises(ValueError) as error:
validate(json)
assert error.value.args == details


# See: https://spacetelescope.github.io/understanding-json-schema/reference/object.html#pattern-properties
@pytest.mark.parametrize('schema', [
rj.dumps({
"type": "object",
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "integer" }
},
"additionalProperties": False
}),
])
@pytest.mark.parametrize('json', [
'{"I_0": 23}',
'{"S_1": "the quick brown fox jumps over the lazy dog"}',
pytest.param('{"I_2": "A string"}', marks=pytest.mark.xfail),
pytest.param('{"keyword": "value"}', marks=pytest.mark.xfail),
])
@pytest.mark.unit
def test_additional_and_pattern_properties_valid(schema, json):
validate = rj.Validator(schema)
validate(json)

0 comments on commit 639b892

Please sign in to comment.