diff options
author | Jared Wasinger <j-wasinger@hotmail.com> | 2017-07-05 06:57:06 +0800 |
---|---|---|
committer | Ubuntu <ubuntu@ip-172-31-32-43.us-west-2.compute.internal> | 2017-08-08 04:41:46 +0800 |
commit | 7378b9fa4e883484af856df99a65c28293613e98 (patch) | |
tree | 8df91e08d40c45c1930df5482c34a3f6f7f17656 /JSONSchema/validate.py | |
parent | 6e8afe6563febbf3f54ab0702aba7056eca762f0 (diff) | |
download | dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.tar dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.tar.gz dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.tar.bz2 dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.tar.lz dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.tar.xz dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.tar.zst dexon-tests-7378b9fa4e883484af856df99a65c28293613e98.zip |
add schema validation with Travis integration.
Diffstat (limited to 'JSONSchema/validate.py')
-rwxr-xr-x | JSONSchema/validate.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/JSONSchema/validate.py b/JSONSchema/validate.py new file mode 100755 index 000000000..086abfa93 --- /dev/null +++ b/JSONSchema/validate.py @@ -0,0 +1,30 @@ +#! /bin/env python + +import glob, json, sys, jsonschema + +with open('JSONSchema/schema.json') as schema_data: + schema = json.load(schema_data) + +#for filename in glob.glob('GeneralStateTests/*.json'): +# print(filename) + +while True: + line = sys.stdin.readline() + if not line: + if success: + sys.exit(0) + else: + sys.exit(-1) + + line = line.strip('\n') + with open(line) as test_data: + test = json.load(test_data) + + try: + jsonschema.validate(test, schema) + except jsonschema.exceptions.ValidationError as e: + success = False + print(line+':\n\n') + print(e) + print('\n') + |