update tests
This commit is contained in:
@ -1 +1 @@
|
||||
{"unicode1_master_slaves_requires.options.unicode.unicode": [], "unicode1_master_slaves_requires.options.unicode.unicode1": [], "unicode1_master_slaves_requires.options.unicode.unicode2": []}
|
||||
{"unicode1_master_slaves_requires.options.unicode.unicode": [], "unicode1_master_slaves_requires.options.unicode.unicode1": [], "unicode1_master_slaves_requires.options.unicode.unicode2": [], "unicode1_master_slaves_requires.options.unicode.unicode3": []}
|
||||
|
@ -1 +1 @@
|
||||
{"unicode1_master_slaves_requires_slave.options.unicode1.unicode1": [], "unicode1_master_slaves_requires_slave.options.unicode1.unicode2": []}
|
||||
{"unicode1_master_slaves_requires_slave.options.unicode1.unicode1": [], "unicode1_master_slaves_requires_slave.options.unicode1.unicode2": [], "unicode1_master_slaves_requires_slave.options.unicode1.unicode3": []}
|
||||
|
@ -1 +1 @@
|
||||
{"unicode1_master_slaves_requires_slave_value.options.unicode1.unicode1": ["test", "pas test"], "unicode1_master_slaves_requires_slave_value.options.unicode1.unicode2": ["super1", null]}
|
||||
{"unicode1_master_slaves_requires_slave_value.options.unicode1.unicode1": ["test", "pas test"], "unicode1_master_slaves_requires_slave_value.options.unicode1.unicode2": ["super1", null], "unicode1_master_slaves_requires_slave_value.options.unicode1.unicode3": ["super1", null]}
|
||||
|
@ -1 +1 @@
|
||||
{"unicode1_master_slaves_requires_slaves.options.unicode1.unicode1": [], "unicode1_master_slaves_requires_slaves.options.unicode1.unicode2": []}
|
||||
{"unicode1_master_slaves_requires_slaves.options.unicode1.unicode1": [], "unicode1_master_slaves_requires_slaves.options.unicode1.unicode2": [], "unicode1_master_slaves_requires_slaves.options.unicode1.unicode3": []}
|
||||
|
1
test/data/unicode1.dict1
Normal file
1
test/data/unicode1.dict1
Normal file
@ -0,0 +1 @@
|
||||
{"options.unicode": "val"}
|
5
test/data/unicode1.mod1
Normal file
5
test/data/unicode1.mod1
Normal file
@ -0,0 +1,5 @@
|
||||
{"cmd": "config.option('options.unicode').value.set('val')",
|
||||
"body": {"updates": [{"action": "modify",
|
||||
"name": "options.unicode",
|
||||
"value": "val"}]}
|
||||
}
|
4
test/data/unicode1.updates1
Normal file
4
test/data/unicode1.updates1
Normal file
@ -0,0 +1,4 @@
|
||||
{"updates": ["options.unicode"],
|
||||
"model": [{"key": "options.unicode",
|
||||
"owner": "user",
|
||||
"value": "val"}]}
|
@ -1 +1 @@
|
||||
{"options.unicode.unicode": [], "options.unicode.unicode1": [], "options.unicode.unicode2": []}
|
||||
{"options.unicode.unicode": [], "options.unicode.unicode1": [], "options.unicode.unicode2": [], "options.unicode.unicode3": []}
|
||||
|
@ -1 +1 @@
|
||||
{"options.unicode1.unicode1": [], "options.unicode1.unicode2": []}
|
||||
{"options.unicode1.unicode1": [], "options.unicode1.unicode2": [], "options.unicode1.unicode3": []}
|
||||
|
@ -1 +1 @@
|
||||
{"options.unicode1.unicode1": ["test", "pas test"], "options.unicode1.unicode2": ["super1", null]}
|
||||
{"options.unicode1.unicode1": ["test", "pas test"], "options.unicode1.unicode2": ["super1", null], "options.unicode1.unicode3": ["super1", null]}
|
||||
|
@ -1 +1 @@
|
||||
{"options.unicode1.unicode1": [], "options.unicode1.unicode2": []}
|
||||
{"options.unicode1.unicode1": [], "options.unicode1.unicode2": [], "options.unicode1.unicode3": []}
|
||||
|
@ -11,12 +11,12 @@ from tiramisu_json_api import Config
|
||||
# warnings.simplefilter("always", ValueWarning)
|
||||
|
||||
|
||||
def list_data():
|
||||
def list_data(ext='.json'):
|
||||
datadir = join(normpath(dirname(abspath(__file__))), 'data')
|
||||
filenames = listdir(datadir)
|
||||
filenames.sort()
|
||||
for filename in filenames:
|
||||
if filename.endswith('.json'):
|
||||
if filename.endswith(ext):
|
||||
yield join(datadir, filename)
|
||||
|
||||
|
||||
@ -24,8 +24,6 @@ def test_dict():
|
||||
debug = False
|
||||
# debug = True
|
||||
for filename in list_data():
|
||||
if 'master' in filename:
|
||||
continue
|
||||
if debug:
|
||||
print('test_jsons', filename)
|
||||
with open(filename, 'r') as fh:
|
||||
@ -33,7 +31,13 @@ def test_dict():
|
||||
#
|
||||
config = Config(json)
|
||||
with open(filename[:-4] + 'dict', 'r') as fh:
|
||||
assert loads(fh.read()) == config.value.dict()
|
||||
dico = loads(fh.read())
|
||||
if debug:
|
||||
from pprint import pprint
|
||||
pprint(dico)
|
||||
print('-----')
|
||||
pprint(config.value.dict())
|
||||
assert dico == config.value.dict()
|
||||
|
||||
|
||||
def test_get():
|
||||
@ -106,3 +110,39 @@ def test_info():
|
||||
if info == 'type' and value in ['filename', 'ip', 'email', 'username']:
|
||||
continue
|
||||
assert getattr(config.option(key).option, info)() == value, 'error for {} in {}'.format(info, filename)
|
||||
|
||||
|
||||
def test_mod():
|
||||
debug = False
|
||||
# debug = True
|
||||
for filename in list_data('.mod1'):
|
||||
if 'master' in filename:
|
||||
continue
|
||||
if debug:
|
||||
print('test_mod', filename)
|
||||
with open(filename[:-4] + 'json', 'r') as fh:
|
||||
json = loads(fh.read())
|
||||
#
|
||||
config = Config(json)
|
||||
with open(filename) as fh:
|
||||
mod = loads(fh.read())
|
||||
eval(mod['cmd'])
|
||||
#
|
||||
if debug:
|
||||
from pprint import pprint
|
||||
pprint(config.updates)
|
||||
print('----------------')
|
||||
pprint(mod['body']['updates'])
|
||||
assert config.updates == mod['body']['updates']
|
||||
#
|
||||
with open(filename[:-4] + 'dict1', 'r') as fh:
|
||||
dico1 = loads(fh.read())
|
||||
assert dico1 == config.value.dict()
|
||||
#
|
||||
with open(filename[:-4] + 'updates1', 'r') as fh:
|
||||
data = loads(fh.read())
|
||||
if debug:
|
||||
from pprint import pprint
|
||||
pprint(data)
|
||||
config.updates_data(data)
|
||||
assert dico1 == config.value.dict()
|
||||
|
Reference in New Issue
Block a user