tiramisu-api-python/test/test_list.py

54 lines
1.4 KiB
Python
Raw Normal View History

2019-04-04 20:04:29 +02:00
from json import loads
from tiramisu_json_api import Config
def test_list_option():
filename = 'test/data/boolean1.json'
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():
filename = 'test/data/boolean1.json'
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():
filename = 'test/data/boolean1.json'
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']