import pytest from jsonschema import validate import ujson as json CON

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pytest
from jsonschema import validate
import ujson as json
CONFIG_V1 = {
'_ver': 1,
'welcome_msg': 'hi',
'lang': 'en',
'steps': [{
'question': 'Foo?',
'answers': ['foo'],
'typez': 'text_answer',
}],
}
CONFIG_V2 = {
'_ver': 2,
'welcome_msg': 'hi',
'welcome_msg_timeout_min': 10,
'lang': 'en',
'steps': [{
'question': 'Foo?',
'answers': ['foo'],
'typez': 'text_answer',
}],
}
def load_schema(ver):
with open('data/schema/config_v%d.json' % ver) as inp:
return json.loads(inp.read())
@pytest.fixture(params=[1, 2])
def version_data(request):
config = globals()['CONFIG_V%d' % request.param]
schema = load_schema(request.param)
return {
'config': config,
'schema': schema,
}
def test_schema(version_data):
validate(version_data['config'], version_data['schema'])