Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)