diff options
author | Julian Berman <Julian@GrayVines.com> | 2022-09-08 09:04:19 +0300 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2022-09-08 09:04:19 +0300 |
commit | 8cec498ad54bbecf38b7eaf304308d500bcda9db (patch) | |
tree | bc6a24f1e79724a15afdec2cb18a69cc65774ad6 /json/tests | |
parent | 05b18609db84954d7309d69d7628cd882ba90dc3 (diff) | |
parent | f5f839a5995c8005373214271989daae3537d70e (diff) | |
download | jsonschema-8cec498ad54bbecf38b7eaf304308d500bcda9db.tar.gz |
Merge commit 'f5f839a5995c8005373214271989daae3537d70e'
* commit 'f5f839a5995c8005373214271989daae3537d70e':
Squashed 'json/' changes from 6eaf7dff4..ed0b855e7
Diffstat (limited to 'json/tests')
-rw-r--r-- | json/tests/draft-next/propertyDependencies.json | 161 | ||||
-rw-r--r-- | json/tests/draft-next/ref.json | 25 | ||||
-rw-r--r-- | json/tests/draft-next/refRemote.json | 48 | ||||
-rw-r--r-- | json/tests/draft2019-09/ref.json | 25 | ||||
-rw-r--r-- | json/tests/draft2019-09/refRemote.json | 48 | ||||
-rw-r--r-- | json/tests/draft2020-12/ref.json | 25 | ||||
-rw-r--r-- | json/tests/draft2020-12/refRemote.json | 48 |
7 files changed, 380 insertions, 0 deletions
diff --git a/json/tests/draft-next/propertyDependencies.json b/json/tests/draft-next/propertyDependencies.json new file mode 100644 index 0000000..9efa2b4 --- /dev/null +++ b/json/tests/draft-next/propertyDependencies.json @@ -0,0 +1,161 @@ +[ + { + "description": "propertyDependencies doesn't act on non-objects", + "schema": { + "propertyDependencies": { + "foo": {"bar": false} + } + }, + "tests": [ + { + "description": "ignores booleans", + "data": true, + "valid": true + }, + { + "description": "ignores integers", + "data": 123, + "valid": true + }, + { + "description": "ignores floats", + "data": 1.0, + "valid": true + }, + { + "description": "ignores strings", + "data": "abc", + "valid": true + }, + { + "description": "ignores arrays", + "data": [], + "valid": true + }, + { + "description": "ignores null", + "data": null, + "valid": true + } + ] + }, + { + "description": "propertyDependencies doesn't act on non-string property values", + "schema": { + "propertyDependencies": { + "foo": {"bar": false} + } + }, + "tests": [ + { + "description": "ignores booleans", + "data": {"foo": false}, + "valid": true + }, + { + "description": "ignores integers", + "data": {"foo": 2}, + "valid": true + }, + { + "description": "ignores floats", + "data": {"foo": 1.1}, + "valid": true + }, + { + "description": "ignores objects", + "data": {"foo": {}}, + "valid": true + }, + { + "description": "ignores objects wth a key of the expected value", + "data": {"foo": {"bar": "baz"}}, + "valid": true + }, + { + "description": "ignores objects with the expected value nested in structure", + "data": {"foo": {"baz": "bar"}}, + "valid": true + }, + { + "description": "ignores arrays", + "data": {"foo": []}, + "valid": true + }, + { + "description": "ignores null", + "data": {"foo": null}, + "valid": true + } + ] + }, + { + "description": "multiple options selects the right one", + "schema": { + "propertyDependencies": { + "foo": { + "bar": { + "minProperties": 2, + "maxProperties": 2 + }, + "baz": {"maxProperties": 1}, + "qux": true, + "quux": false + } + } + }, + "tests": [ + { + "description": "bar with exactly 2 properties is valid", + "data": { + "foo": "bar", + "other-foo": "other-bar" + }, + "valid": true + }, + { + "description": "bar with more than 2 properties is invalid", + "data": { + "foo": "bar", + "other-foo": "other-bar", + "too": "many" + }, + "valid": false + }, + { + "description": "bar with fewer than 2 properties is invalid", + "data": {"foo": "bar"}, + "valid": false + }, + { + "description": "baz alone is valid", + "data": {"foo": "baz"}, + "valid": true + }, + { + "description": "baz with other properties is invalid", + "data": { + "foo": "baz", + "other-foo": "other-bar" + }, + "valid": false + }, + { + "description": "anything allowed with qux", + "data": { + "foo": "qux", + "blah": ["some other property"], + "more": "properties" + }, + "valid": true + }, + { + "description": "quux is disallowed", + "data": { + "foo": "quux" + }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft-next/ref.json b/json/tests/draft-next/ref.json index 2a58ef8..8e0fbb6 100644 --- a/json/tests/draft-next/ref.json +++ b/json/tests/draft-next/ref.json @@ -858,5 +858,30 @@ "valid": false } ] + }, + { + "description": "URN ref with nested pointer ref", + "schema": { + "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "$defs": { + "foo": { + "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "$defs": {"bar": {"type": "string"}}, + "$ref": "#/$defs/bar" + } + } + }, + "tests": [ + { + "description": "a string is valid", + "data": "bar", + "valid": true + }, + { + "description": "a non-string is invalid", + "data": 12, + "valid": false + } + ] } ] diff --git a/json/tests/draft-next/refRemote.json b/json/tests/draft-next/refRemote.json index 43070a8..ca5b8c4 100644 --- a/json/tests/draft-next/refRemote.json +++ b/json/tests/draft-next/refRemote.json @@ -243,5 +243,53 @@ "valid": true } ] + }, + { + "description": "remote HTTP ref with different $id", + "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "remote HTTP ref with different URN $id", + "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "remote HTTP ref with nested absolute ref", + "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] } ] diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json index 8501152..3142cd9 100644 --- a/json/tests/draft2019-09/ref.json +++ b/json/tests/draft2019-09/ref.json @@ -858,5 +858,30 @@ "valid": false } ] + }, + { + "description": "URN ref with nested pointer ref", + "schema": { + "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "$defs": { + "foo": { + "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "$defs": {"bar": {"type": "string"}}, + "$ref": "#/$defs/bar" + } + } + }, + "tests": [ + { + "description": "a string is valid", + "data": "bar", + "valid": true + }, + { + "description": "a non-string is invalid", + "data": 12, + "valid": false + } + ] } ] diff --git a/json/tests/draft2019-09/refRemote.json b/json/tests/draft2019-09/refRemote.json index 944820f..7f45b0b 100644 --- a/json/tests/draft2019-09/refRemote.json +++ b/json/tests/draft2019-09/refRemote.json @@ -243,5 +243,53 @@ "valid": true } ] + }, + { + "description": "remote HTTP ref with different $id", + "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "remote HTTP ref with different URN $id", + "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "remote HTTP ref with nested absolute ref", + "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] } ] diff --git a/json/tests/draft2020-12/ref.json b/json/tests/draft2020-12/ref.json index 232cc7d..2b9c481 100644 --- a/json/tests/draft2020-12/ref.json +++ b/json/tests/draft2020-12/ref.json @@ -858,5 +858,30 @@ "valid": false } ] + }, + { + "description": "URN ref with nested pointer ref", + "schema": { + "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "$defs": { + "foo": { + "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", + "$defs": {"bar": {"type": "string"}}, + "$ref": "#/$defs/bar" + } + } + }, + "tests": [ + { + "description": "a string is valid", + "data": "bar", + "valid": true + }, + { + "description": "a non-string is invalid", + "data": 12, + "valid": false + } + ] } ] diff --git a/json/tests/draft2020-12/refRemote.json b/json/tests/draft2020-12/refRemote.json index 433eb1d..d3cc401 100644 --- a/json/tests/draft2020-12/refRemote.json +++ b/json/tests/draft2020-12/refRemote.json @@ -243,5 +243,53 @@ "valid": true } ] + }, + { + "description": "remote HTTP ref with different $id", + "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "remote HTTP ref with different URN $id", + "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] + }, + { + "description": "remote HTTP ref with nested absolute ref", + "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"}, + "tests": [ + { + "description": "number is invalid", + "data": 1, + "valid": false + }, + { + "description": "string is valid", + "data": "foo", + "valid": true + } + ] } ] |