Skip to content

Commit

Permalink
Squashed 'json/' changes from 3c3881a..15ba997
Browse files Browse the repository at this point in the history
15ba997 Merge pull request python-jsonschema#259 from epoberezkin/epoberezkin/special-chars
6f74063 ref with quote
5bb7a0d dependencies with escaped characters
96085b7 enum with escaped characters
4019147 required with escaped characters
6e97672 properties with escaped characters
92eeeb4 Merge pull request python-jsonschema#258 from gzzi/master
60d5ff4 Add test with negative integer for minimum in draft 3/4/6
25710d0 Add test with negative integer for minimum

git-subtree-dir: json
git-subtree-split: 15ba997f9b937150a0ab88244d1d0fbf58526c48
  • Loading branch information
Julian committed Mar 31, 2019
1 parent a1ade0a commit eb60af0
Show file tree
Hide file tree
Showing 19 changed files with 709 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/draft3/minimum.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 38,36 @@
"valid": false
}
]
},
{
"description": "minimum validation with signed integer",
"schema": {"minimum": -2},
"tests": [
{
"description": "negative above the minimum is valid",
"data": -1,
"valid": true
},
{
"description": "positive above the minimum is valid",
"data": 0,
"valid": true
},
{
"description": "boundary point is valid",
"data": -2,
"valid": true
},
{
"description": "below the minimum is invalid",
"data": -3,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "x",
"valid": true
}
]
}
]
71 changes: 71 additions & 0 deletions tests/draft4/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 119,76 @@
"valid": false
}
]
},
{
"description": "dependencies with escaped characters",
"schema": {
"dependencies": {
"foo\nbar": ["foo\rbar"],
"foo\tbar": {
"minProperties": 4
},
"foo'bar": {"required": ["foo\"bar"]},
"foo\"bar": ["foo'bar"]
}
},
"tests": [
{
"description": "valid object 1",
"data": {
"foo\nbar": 1,
"foo\rbar": 2
},
"valid": true
},
{
"description": "valid object 2",
"data": {
"foo\tbar": 1,
"a": 2,
"b": 3,
"c": 4
},
"valid": true
},
{
"description": "valid object 3",
"data": {
"foo'bar": 1,
"foo\"bar": 2
},
"valid": true
},
{
"description": "invalid object 1",
"data": {
"foo\nbar": 1,
"foo": 2
},
"valid": false
},
{
"description": "invalid object 2",
"data": {
"foo\tbar": 1,
"a": 2
},
"valid": false
},
{
"description": "invalid object 3",
"data": {
"foo'bar": 1
},
"valid": false
},
{
"description": "invalid object 4",
"data": {
"foo\"bar": 2
},
"valid": false
}
]
}
]
23 changes: 23 additions & 0 deletions tests/draft4/enum.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 68,28 @@
"valid": false
}
]
},
{
"description": "enum with escaped characters",
"schema": {
"enum": ["foo\nbar", "foo\rbar"]
},
"tests": [
{
"description": "member 1 is valid",
"data": "foo\nbar",
"valid": true
},
{
"description": "member 2 is valid",
"data": "foo\rbar",
"valid": true
},
{
"description": "another string is invalid",
"data": "abc",
"valid": false
}
]
}
]
31 changes: 31 additions & 0 deletions tests/draft4/minimum.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 69,36 @@
"valid": false
}
]
},
{
"description": "minimum validation with signed integer",
"schema": {"minimum": -2},
"tests": [
{
"description": "negative above the minimum is valid",
"data": -1,
"valid": true
},
{
"description": "positive above the minimum is valid",
"data": 0,
"valid": true
},
{
"description": "boundary point is valid",
"data": -2,
"valid": true
},
{
"description": "below the minimum is invalid",
"data": -3,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "x",
"valid": true
}
]
}
]
39 changes: 39 additions & 0 deletions tests/draft4/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 93,44 @@
"valid": false
}
]
},
{
"description": "properties with escaped characters",
"schema": {
"properties": {
"foo\nbar": {"type": "number"},
"foo\"bar": {"type": "number"},
"foo\\bar": {"type": "number"},
"foo\rbar": {"type": "number"},
"foo\tbar": {"type": "number"},
"foo\fbar": {"type": "number"}
}
},
"tests": [
{
"description": "object with all numbers is valid",
"data": {
"foo\nbar": 1,
"foo\"bar": 1,
"foo\\bar": 1,
"foo\rbar": 1,
"foo\tbar": 1,
"foo\fbar": 1
},
"valid": true
},
{
"description": "object with strings is invalid",
"data": {
"foo\nbar": "1",
"foo\"bar": "1",
"foo\\bar": "1",
"foo\rbar": "1",
"foo\tbar": "1",
"foo\fbar": "1"
},
"valid": false
}
]
}
]
27 changes: 27 additions & 0 deletions tests/draft4/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 296,32 @@
"valid": false
}
]
},
{
"description": "refs with quote",
"schema": {
"properties": {
"foo\"bar": {"$ref": "#/definitions/foo\"bar"}
},
"definitions": {
"foo\"bar": {"type": "number"}
}
},
"tests": [
{
"description": "object with numbers is valid",
"data": {
"foo\"bar": 1
},
"valid": true
},
{
"description": "object with strings is invalid",
"data": {
"foo\"bar": "1"
},
"valid": false
}
]
}
]
35 changes: 35 additions & 0 deletions tests/draft4/required.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 50,40 @@
"valid": true
}
]
},
{
"description": "required with escaped characters",
"schema": {
"required": [
"foo\nbar",
"foo\"bar",
"foo\\bar",
"foo\rbar",
"foo\tbar",
"foo\fbar"
]
},
"tests": [
{
"description": "object with all properties present is valid",
"data": {
"foo\nbar": 1,
"foo\"bar": 1,
"foo\\bar": 1,
"foo\rbar": 1,
"foo\tbar": 1,
"foo\fbar": 1
},
"valid": true
},
{
"description": "object with some properties missing is invalid",
"data": {
"foo\nbar": "1",
"foo\"bar": "1"
},
"valid": false
}
]
}
]
71 changes: 71 additions & 0 deletions tests/draft6/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 193,76 @@
"valid": true
}
]
},
{
"description": "dependencies with escaped characters",
"schema": {
"dependencies": {
"foo\nbar": ["foo\rbar"],
"foo\tbar": {
"minProperties": 4
},
"foo'bar": {"required": ["foo\"bar"]},
"foo\"bar": ["foo'bar"]
}
},
"tests": [
{
"description": "valid object 1",
"data": {
"foo\nbar": 1,
"foo\rbar": 2
},
"valid": true
},
{
"description": "valid object 2",
"data": {
"foo\tbar": 1,
"a": 2,
"b": 3,
"c": 4
},
"valid": true
},
{
"description": "valid object 3",
"data": {
"foo'bar": 1,
"foo\"bar": 2
},
"valid": true
},
{
"description": "invalid object 1",
"data": {
"foo\nbar": 1,
"foo": 2
},
"valid": false
},
{
"description": "invalid object 2",
"data": {
"foo\tbar": 1,
"a": 2
},
"valid": false
},
{
"description": "invalid object 3",
"data": {
"foo'bar": 1
},
"valid": false
},
{
"description": "invalid object 4",
"data": {
"foo\"bar": 2
},
"valid": false
}
]
}
]
Loading

0 comments on commit eb60af0

Please sign in to comment.