2019-04-04 20:04:29 +02:00
|
|
|
from json import loads
|
|
|
|
from tiramisu_json_api import Config
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_option():
|
2019-07-06 15:01:13 +02:00
|
|
|
filename = 'tests/data/boolean1.json'
|
2019-04-04 20:04:29 +02:00
|
|
|
with open(filename, 'r') as fh:
|
|
|
|
json = loads(fh.read())
|
|
|
|
#
|
|
|
|
config = Config(json)
|
|
|
|
opts = []
|
|
|
|
for option in config.option.list():
|
|
|
|
opts.append(option.option.name())
|
|
|
|
assert opts == []
|
|
|
|
#
|
|
|
|
opts = []
|
|
|
|
for option in config.option('options').list():
|
|
|
|
opts.append(option.option.name())
|
|
|
|
assert opts == ['boolean']
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_optiondescription():
|
2019-07-06 15:01:13 +02:00
|
|
|
filename = 'tests/data/boolean1.json'
|
2019-04-04 20:04:29 +02:00
|
|
|
with open(filename, 'r') as fh:
|
|
|
|
json = loads(fh.read())
|
|
|
|
#
|
|
|
|
config = Config(json)
|
|
|
|
opts = []
|
|
|
|
for option in config.option.list('optiondescription'):
|
|
|
|
opts.append(option.option.name())
|
|
|
|
assert opts == ['options']
|
|
|
|
#
|
|
|
|
opts = []
|
|
|
|
for option in config.option('options').list('optiondescription'):
|
|
|
|
opts.append(option.option.name())
|
|
|
|
assert opts == []
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_all():
|
2019-07-06 15:01:13 +02:00
|
|
|
filename = 'tests/data/boolean1.json'
|
2019-04-04 20:04:29 +02:00
|
|
|
with open(filename, 'r') as fh:
|
|
|
|
json = loads(fh.read())
|
|
|
|
#
|
|
|
|
config = Config(json)
|
|
|
|
opts = []
|
|
|
|
for option in config.option.list('all'):
|
|
|
|
opts.append(option.option.name())
|
|
|
|
assert opts == ['options']
|
|
|
|
#
|
|
|
|
opts = []
|
|
|
|
for option in config.option('options').list('all'):
|
|
|
|
opts.append(option.option.name())
|
|
|
|
assert opts == ['boolean']
|