Skip to content

Commit a57d854

Browse files
committed
Squashed 'json/' changes from ea415537..86f52b87
86f52b87 Fix a clear copy-paste error in the case names for tests from #394. ec18a7d0 Merge pull request #360 from notEthan/duplicate_uris cd9a4b9d change schemas with duplicate URIs http://localhost:1234/folder/ 43e190e0 Merge pull request #394 from rjmill/rjmill/bools-and-1s-and-0s-inside-objects-and-arrays 85f0d459 Merge pull request #419 from ChALkeR/chalker/format-uri 54436216 Merge pull request #420 from ChALkeR/chalker/format/ip6 ad47b726 Add long valid and invalid ipv6 b2ab70ec More optional ipv6 tests 37189ae6 Test that uri format scheme is validated for allowed chars 2106ed17 backport uniqueItems cases to draft3 49fc2a95 backport const test cases to draft6 79fe60c0 more tests for true != 1 and false != 0 inside objects/arrays git-subtree-dir: json git-subtree-split: 86f52b87e3d572b8f808dd074a6b95c3695ba992
1 parent 95874db commit a57d854

File tree

25 files changed

+486
-16
lines changed

25 files changed

+486
-16
lines changed

bin/jsonschema_suite

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ REMOTES = {
5151
u"refToInteger": {u"$ref": u"#/$defs/integer"},
5252
}
5353
},
54-
"folder/folderInteger.json": {u"type": u"integer"}
54+
"baseUriChange/folderInteger.json": {u"type": u"integer"},
55+
"baseUriChangeFolder/folderInteger.json": {u"type": u"integer"},
56+
"baseUriChangeFolderInSubschema/folderInteger.json": {u"type": u"integer"},
5557
}
5658
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
5759

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "integer"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "integer"
3+
}

tests/draft2019-09/const.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,90 @@
125125
}
126126
]
127127
},
128+
{
129+
"description": "const with [false] does not match [0]",
130+
"schema": {"const": [false]},
131+
"tests": [
132+
{
133+
"description": "[false] is valid",
134+
"data": [false],
135+
"valid": true
136+
},
137+
{
138+
"description": "[0] is invalid",
139+
"data": [0],
140+
"valid": false
141+
},
142+
{
143+
"description": "[0.0] is invalid",
144+
"data": [0.0],
145+
"valid": false
146+
}
147+
]
148+
},
149+
{
150+
"description": "const with [true] does not match [1]",
151+
"schema": {"const": [true]},
152+
"tests": [
153+
{
154+
"description": "[true] is valid",
155+
"data": [true],
156+
"valid": true
157+
},
158+
{
159+
"description": "[1] is invalid",
160+
"data": [1],
161+
"valid": false
162+
},
163+
{
164+
"description": "[1.0] is invalid",
165+
"data": [1.0],
166+
"valid": false
167+
}
168+
]
169+
},
170+
{
171+
"description": "const with {\"a\": false} does not match {\"a\": 0}",
172+
"schema": {"const": {"a": false}},
173+
"tests": [
174+
{
175+
"description": "{\"a\": false} is valid",
176+
"data": {"a": false},
177+
"valid": true
178+
},
179+
{
180+
"description": "{\"a\": 0} is invalid",
181+
"data": {"a": 0},
182+
"valid": false
183+
},
184+
{
185+
"description": "{\"a\": 0.0} is invalid",
186+
"data": {"a": 0.0},
187+
"valid": false
188+
}
189+
]
190+
},
191+
{
192+
"description": "const with {\"a\": true} does not match {\"a\": 1}",
193+
"schema": {"const": {"a": true}},
194+
"tests": [
195+
{
196+
"description": "{\"a\": true} is valid",
197+
"data": {"a": true},
198+
"valid": true
199+
},
200+
{
201+
"description": "{\"a\": 1} is invalid",
202+
"data": {"a": 1},
203+
"valid": false
204+
},
205+
{
206+
"description": "{\"a\": 1.0} is invalid",
207+
"data": {"a": 1.0},
208+
"valid": false
209+
}
210+
]
211+
},
128212
{
129213
"description": "const with 0 does not match other zero-like types",
130214
"schema": {"const": 0},

tests/draft2019-09/optional/format/ipv6.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,41 @@
112112
"description": "ipv4 segment must have 4 octets",
113113
"data": "1:2:3:4:1.2.3",
114114
"valid": false
115+
},
116+
{
117+
"description": "leading whitespace is invalid",
118+
"data": " ::1",
119+
"valid": false
120+
},
121+
{
122+
"description": "trailing whitespace is invalid",
123+
"data": "::1 ",
124+
"valid": false
125+
},
126+
{
127+
"description": "netmask is not a part of ipv6 address",
128+
"data": "fe80::/64",
129+
"valid": false
130+
},
131+
{
132+
"description": "zone id is not a part of ipv6 address",
133+
"data": "fe80::a%eth1",
134+
"valid": false
135+
},
136+
{
137+
"description": "a long valid ipv6",
138+
"data": "1000:1000:1000:1000:1000:1000:255.255.255.255",
139+
"valid": true
140+
},
141+
{
142+
"description": "a long invalid ipv6, below length limit, first",
143+
"data": "100:100:100:100:100:100:255.255.255.255.255",
144+
"valid": false
145+
},
146+
{
147+
"description": "a long invalid ipv6, below length limit, second",
148+
"data": "100:100:100:100:100:100:100:255.255.255.255",
149+
"valid": false
115150
}
116151
]
117152
}

tests/draft2019-09/optional/format/uri.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
"description": "an invalid URI with spaces and missing scheme",
9898
"data": ":// should fail",
9999
"valid": false
100+
},
101+
{
102+
"description": "an invalid URI with comma in scheme",
103+
"data": "bar,baz:foo",
104+
"valid": false
100105
}
101106
]
102107
}

tests/draft2019-09/refRemote.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"schema": {
5555
"$id": "http://localhost:1234/",
5656
"items": {
57-
"$id": "folder/",
57+
"$id": "baseUriChange/",
5858
"items": {"$ref": "folderInteger.json"}
5959
}
6060
},
@@ -76,10 +76,10 @@
7676
"schema": {
7777
"$id": "http://localhost:1234/scope_change_defs1.json",
7878
"type" : "object",
79-
"properties": {"list": {"$ref": "folder/"}},
79+
"properties": {"list": {"$ref": "baseUriChangeFolder/"}},
8080
"$defs": {
8181
"baz": {
82-
"$id": "folder/",
82+
"$id": "baseUriChangeFolder/",
8383
"type": "array",
8484
"items": {"$ref": "folderInteger.json"}
8585
}
@@ -103,10 +103,10 @@
103103
"schema": {
104104
"$id": "http://localhost:1234/scope_change_defs2.json",
105105
"type" : "object",
106-
"properties": {"list": {"$ref": "folder/#/$defs/bar"}},
106+
"properties": {"list": {"$ref": "baseUriChangeFolderInSubschema/#/$defs/bar"}},
107107
"$defs": {
108108
"baz": {
109-
"$id": "folder/",
109+
"$id": "baseUriChangeFolderInSubschema/",
110110
"$defs": {
111111
"bar": {
112112
"type": "array",

tests/draft2019-09/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "objects are non-unique despite key order",
114114
"data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
115115
"valid": false
116+
},
117+
{
118+
"description": "{\"a\": false} and {\"a\": 0} are unique",
119+
"data": [{"a": false}, {"a": 0}],
120+
"valid": true
121+
},
122+
{
123+
"description": "{\"a\": true} and {\"a\": 1} are unique",
124+
"data": [{"a": true}, {"a": 1}],
125+
"valid": true
116126
}
117127
]
118128
},

tests/draft3/refRemote.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"schema": {
5555
"id": "http://localhost:1234/",
5656
"items": {
57-
"id": "folder/",
57+
"id": "baseUriChange/",
5858
"items": {"$ref": "folderInteger.json"}
5959
}
6060
},

tests/draft3/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@
9393
"description": "non-unique heterogeneous types are invalid",
9494
"data": [{}, [1], true, null, {}, 1],
9595
"valid": false
96+
},
97+
{
98+
"description": "{\"a\": false} and {\"a\": 0} are unique",
99+
"data": [{"a": false}, {"a": 0}],
100+
"valid": true
101+
},
102+
{
103+
"description": "{\"a\": true} and {\"a\": 1} are unique",
104+
"data": [{"a": true}, {"a": 1}],
105+
"valid": true
96106
}
97107
]
98108
},

tests/draft4/optional/format/ipv6.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,41 @@
112112
"description": "ipv4 segment must have 4 octets",
113113
"data": "1:2:3:4:1.2.3",
114114
"valid": false
115+
},
116+
{
117+
"description": "leading whitespace is invalid",
118+
"data": " ::1",
119+
"valid": false
120+
},
121+
{
122+
"description": "trailing whitespace is invalid",
123+
"data": "::1 ",
124+
"valid": false
125+
},
126+
{
127+
"description": "netmask is not a part of ipv6 address",
128+
"data": "fe80::/64",
129+
"valid": false
130+
},
131+
{
132+
"description": "zone id is not a part of ipv6 address",
133+
"data": "fe80::a%eth1",
134+
"valid": false
135+
},
136+
{
137+
"description": "a long valid ipv6",
138+
"data": "1000:1000:1000:1000:1000:1000:255.255.255.255",
139+
"valid": true
140+
},
141+
{
142+
"description": "a long invalid ipv6, below length limit, first",
143+
"data": "100:100:100:100:100:100:255.255.255.255.255",
144+
"valid": false
145+
},
146+
{
147+
"description": "a long invalid ipv6, below length limit, second",
148+
"data": "100:100:100:100:100:100:100:255.255.255.255",
149+
"valid": false
115150
}
116151
]
117152
}

tests/draft4/optional/format/uri.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
"description": "an invalid URI with spaces and missing scheme",
9898
"data": ":// should fail",
9999
"valid": false
100+
},
101+
{
102+
"description": "an invalid URI with comma in scheme",
103+
"data": "bar,baz:foo",
104+
"valid": false
100105
}
101106
]
102107
}

tests/draft4/refRemote.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"schema": {
5555
"id": "http://localhost:1234/",
5656
"items": {
57-
"id": "folder/",
57+
"id": "baseUriChange/",
5858
"items": {"$ref": "folderInteger.json"}
5959
}
6060
},
@@ -81,7 +81,7 @@
8181
},
8282
"definitions": {
8383
"baz": {
84-
"id": "folder/",
84+
"id": "baseUriChangeFolder/",
8585
"type": "array",
8686
"items": {"$ref": "folderInteger.json"}
8787
}
@@ -110,7 +110,7 @@
110110
},
111111
"definitions": {
112112
"baz": {
113-
"id": "folder/",
113+
"id": "baseUriChangeFolderInSubschema/",
114114
"definitions": {
115115
"bar": {
116116
"type": "array",

tests/draft4/uniqueItems.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@
113113
"description": "objects are non-unique despite key order",
114114
"data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
115115
"valid": false
116+
},
117+
{
118+
"description": "{\"a\": false} and {\"a\": 0} are unique",
119+
"data": [{"a": false}, {"a": 0}],
120+
"valid": true
121+
},
122+
{
123+
"description": "{\"a\": true} and {\"a\": 1} are unique",
124+
"data": [{"a": true}, {"a": 1}],
125+
"valid": true
116126
}
117127
]
118128
},

0 commit comments

Comments
 (0)