34 lines
746 B
Python
34 lines
746 B
Python
# standard imports
|
|
import unittest
|
|
import json
|
|
import os
|
|
|
|
# external imports
|
|
from jsonschema import validate as json_validate
|
|
|
|
test_dir = os.path.realpath(os.path.dirname(__file__))
|
|
testdata_dir = os.path.join(test_dir, 'testdata')
|
|
data_dir = os.path.join(test_dir, '..', 'cic_schema', 'data')
|
|
|
|
|
|
class TestJsonData(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
fp = os.path.join(data_dir, 'cic.json')
|
|
f = open(fp, 'r')
|
|
self.schema = json.load(f)
|
|
f.close()
|
|
|
|
|
|
def test_schema_load(self):
|
|
fp = os.path.join(testdata_dir, 'test_valid.json')
|
|
f = open(fp, 'r')
|
|
o = json.load(f)
|
|
f.close()
|
|
validator = json_validate(o, self.schema)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|