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'])