From 4e8bf598b5567a19c9a3d2069434fec55e9458c8 Mon Sep 17 00:00:00 2001 From: Anthony Miyaguchi Date: Sat, 2 Jun 2018 12:24:27 -0700 Subject: [PATCH 1/2] Add failing tests for additionalProperties and patternProperties --- tests/test_validator.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_validator.py b/tests/test_validator.py index e40026e..d399902 100644 --- a/tests/test_validator.py +++ b/tests/test_validator.py @@ -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) From 6fa94ccb735bb3781b80e72ef3dccad5e77b0ee2 Mon Sep 17 00:00:00 2001 From: Anthony Miyaguchi Date: Sat, 2 Jun 2018 12:37:56 -0700 Subject: [PATCH 2/2] Track rapidjson@67a17cfd for bugfixes --- rapidjson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapidjson b/rapidjson index f54b0e4..67a17cf 160000 --- a/rapidjson +++ b/rapidjson @@ -1 +1 @@ -Subproject commit f54b0e47a08782a6131cc3d60f94d038fa6e0a51 +Subproject commit 67a17cfdbc25ff1fc8d01714be87e242b03a4cc9