json/schema: move validation test cases to own directory
This commit is contained in:
parent
195616f563
commit
19fdbaefb7
@ -13,7 +13,7 @@ src="@CMAKE_CURRENT_SOURCE_DIR@/test/json/schema"
|
||||
devnull=open(os.devnull, 'w')
|
||||
|
||||
|
||||
def test_bad(schema, dir):
|
||||
def test_bad(schema:str, dir:str) -> int:
|
||||
failures = 0
|
||||
|
||||
for input in glob(os.path.join(dir, "*.json")):
|
||||
@ -30,7 +30,7 @@ def test_bad(schema, dir):
|
||||
return failures
|
||||
|
||||
|
||||
def test_good(schema, dir):
|
||||
def test_good(schema:str, dir:str) -> int:
|
||||
inputs = glob(os.path.join(dir, "*.input.json"))
|
||||
results = glob(os.path.join(dir, "*.result.json"))
|
||||
|
||||
@ -56,7 +56,7 @@ def test_good(schema, dir):
|
||||
return failures
|
||||
|
||||
|
||||
def test_pool(dir):
|
||||
def validation_group(dir:str) -> int:
|
||||
schema = os.path.join(dir, "schema.json")
|
||||
if not os.path.isfile(schema):
|
||||
raise Exception("schema is not present")
|
||||
@ -67,15 +67,24 @@ def test_pool(dir):
|
||||
|
||||
return failures
|
||||
|
||||
def test_validation(dir:str) -> int:
|
||||
failures = 0
|
||||
|
||||
groups = (x for x in os.listdir(dir))
|
||||
groups = (os.path.join(dir, x) for x in groups)
|
||||
groups = (x for x in groups if os.path.isdir(x))
|
||||
|
||||
for name in sorted(groups):
|
||||
path = os.path.join(src, name)
|
||||
if not os.path.isdir(path):
|
||||
continue
|
||||
failures += validation_group(path)
|
||||
|
||||
return failures
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
failures = 0
|
||||
|
||||
for name in os.listdir(src):
|
||||
path = os.path.join(src, name)
|
||||
if not os.path.isdir(path):
|
||||
continue
|
||||
failures += test_pool(path)
|
||||
|
||||
failures += test_validation(os.path.join(src, "validation"))
|
||||
exit(1 if failures else 0)
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
[true]
|
@ -0,0 +1 @@
|
||||
{"val": true}
|
@ -0,0 +1 @@
|
||||
false
|
1
test/json/schema/validation/3000_bool_null/schema.json
Normal file
1
test/json/schema/validation/3000_bool_null/schema.json
Normal file
@ -0,0 +1 @@
|
||||
{ "type": "boolean" }
|
@ -0,0 +1 @@
|
||||
true
|
@ -0,0 +1 @@
|
||||
null
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1 @@
|
||||
"foo"
|
Loading…
Reference in New Issue
Block a user