test_elx_schemas.py 636 Bytes
Newer Older
Pinar Alper's avatar
Pinar Alper committed
1
2
3
4
5
6
7
8
9
10
11
12
from unittest import TestCase
from json import loads
from jsonschema import validate
import os


class TestParser(TestCase):



    def test_validation(self):

Pinar Alper's avatar
Pinar Alper committed
13
14
15
        print(os.getcwd())
        schemaFile = open('../../metadata_tools/resources/elu-dataset.json', encoding='utf-8')
        dataFile = open('data/datasets.json', encoding='utf-8')
Pinar Alper's avatar
Pinar Alper committed
16
17

        schema = loads(schemaFile.read())
18
19
20
21
22
23
24
25
26
27
        data = loads(dataFile.read())

        try:
            validate(data, schema['schema'])
            self.assert_(True)
        except:
            self.fail()
        finally:
            dataFile.close()
            schemaFile.close()
Pinar Alper's avatar
Pinar Alper committed
28
29