leadership support

This commit is contained in:
2019-03-16 22:51:39 +01:00
parent aad8157b98
commit df7fc3fc8f
38 changed files with 186 additions and 72 deletions

1
test/data/unicode1.dict1 Normal file
View File

@ -0,0 +1 @@
{"options.unicode": "val"}

1
test/data/unicode1.mod1 Normal file
View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode').value.set('val')", "body": {"updates": [{"action": "modify", "name": "options.unicode", "value": "val"}]}}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode"], "model": [{"key": "options.unicode", "owner": "user", "value": "val"}]}

View File

@ -0,0 +1 @@
{"options.unicode.unicode": ["val1", "val2"], "options.unicode.unicode1": [null, null], "options.unicode.unicode2": ["follower2", "follower2"], "options.unicode.unicode3": [null, null]}

View File

@ -0,0 +1 @@
{"options.unicode.unicode": ["val3"], "options.unicode.unicode1": ["super1"], "options.unicode.unicode2": ["pas test"], "options.unicode.unicode3": [null]}

View File

@ -0,0 +1 @@
{"options.unicode.unicode": ["val3", "val4", "val5"], "options.unicode.unicode1": ["super1", "super2", null], "options.unicode.unicode2": ["pas test", "test", "follower2"], "options.unicode.unicode3": [null, "super", null]}

View File

@ -0,0 +1 @@
{"options.unicode.unicode": ["val3", "val4", "val5"], "options.unicode.unicode1": ["super1", "super2", null], "options.unicode.unicode2": ["pas test", "test", "follower2"], "options.unicode.unicode3": [null, "super", null]}

View File

@ -0,0 +1 @@
{"options.unicode.unicode": ["val3", "val4"], "options.unicode.unicode1": ["super1", "super2"], "options.unicode.unicode2": ["pas test", "follower2"], "options.unicode.unicode3": [null, "super"]}

View File

@ -0,0 +1 @@
{"options.unicode.unicode": ["val3", "val4"], "options.unicode.unicode1": ["super1", "super2"], "options.unicode.unicode2": ["pas test", "test2"], "options.unicode.unicode3": [null, "super"]}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode.unicode').value.reset()", "body": {"updates": [{"action": "delete", "name": "options.unicode.unicode"}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode.unicode', 1).value.reset()", "body": {"updates": [{"action": "delete", "index": 1, "name": "options.unicode.unicode"}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode.unicode').value.set(['val3', 'val4', 'val5'])", "body": {"updates": [{"action": "modify", "name": "options.unicode.unicode", "value": ["val3", "val4", "val5"]}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode.unicode').value.set(['val3', 'val4', 'val5'])", "body": {"updates": [{"action": "modify", "name": "options.unicode.unicode", "value": ["val3", "val4", "val5"]}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode.unicode2', 1).value.reset()", "body": {"updates": [{"action": "delete", "name": "options.unicode.unicode2", "index": 1}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode.unicode2', 1).value.set('test2')", "body": {"updates": [{"action": "modify", "name": "options.unicode.unicode2", "index": 1, "value": "test2"}]}}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode.unicode", "options.unicode.unicode1", "options.unicode.unicode2", "options.unicode.unicode3"], "model": [{"key": "options.unicode.unicode", "owner": "default", "required": true, "value": ["val1", "val2"]}, {"index": 0, "key": "options.unicode.unicode2", "owner": "default", "value": "follower2"}, {"index": 1, "key": "options.unicode.unicode2", "owner": "default", "value": "follower2"}]}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode.unicode", "options.unicode.unicode1", "options.unicode.unicode2", "options.unicode.unicode3"], "model": [{"key": "options.unicode.unicode", "required": true, "value": ["val3"], "owner": "user"}, {"key": "options.unicode.unicode1", "index": 0, "value": "super1", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 0, "value": "pas test", "owner": "user"}]}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode.unicode", "options.unicode.unicode2"], "model": [{"key": "options.unicode.unicode", "required": true, "value": ["val3", "val4", "val5"], "owner": "user"}, {"key": "options.unicode.unicode1", "index": 0, "value": "super1", "owner": "user"}, {"key": "options.unicode.unicode1", "index": 1, "value": "super2", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 0, "value": "pas test", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 1, "value": "test", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 2, "value": "follower2", "owner": "default"}, {"key": "options.unicode.unicode3", "index": 1, "value": "super", "owner": "user"}]}

View File

@ -0,0 +1 @@
{"model": [{"key": "options.unicode.unicode", "owner": "user", "required": true, "value": ["val3", "val4", "val5"]}, {"index": 0, "key": "options.unicode.unicode1", "owner": "user", "value": "super1"}, {"index": 1, "key": "options.unicode.unicode1", "owner": "user", "value": "super2"}, {"index": 0, "key": "options.unicode.unicode2", "owner": "user", "value": "pas test"}, {"index": 1, "key": "options.unicode.unicode2", "owner": "user", "value": "test"}, {"index": 2, "key": "options.unicode.unicode2", "owner": "default", "value": "follower2"}, {"index": 1, "key": "options.unicode.unicode3", "owner": "user", "value": "super"}], "updates": ["options.unicode.unicode", "options.unicode.unicode2"]}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode.unicode2"], "model": [{"key": "options.unicode.unicode", "required": true, "value": ["val3", "val4"], "owner": "user"}, {"key": "options.unicode.unicode1", "index": 0, "value": "super1", "owner": "user"}, {"key": "options.unicode.unicode1", "index": 1, "value": "super2", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 0, "value": "pas test", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 1, "value": "follower2", "owner": "default"}, {"key": "options.unicode.unicode3", "index": 1, "value": "super", "owner": "user"}]}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode.unicode2"], "model": [{"key": "options.unicode.unicode", "required": true, "value": ["val3", "val4"], "owner": "user"}, {"key": "options.unicode.unicode1", "index": 0, "value": "super1", "owner": "user"}, {"key": "options.unicode.unicode1", "index": 1, "value": "super2", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 0, "value": "pas test", "owner": "user"}, {"key": "options.unicode.unicode2", "index": 1, "value": "test2", "owner": "user"}, {"key": "options.unicode.unicode3", "index": 1, "value": "super", "owner": "user"}]}

View File

@ -0,0 +1 @@
{"options.unicode": "val"}

View File

@ -0,0 +1 @@
{"options.unicode": null}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode').value.set('val')", "body": {"updates": [{"action": "modify", "name": "options.unicode", "value": "val"}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode').value.reset()", "body": {"updates": [{"action": "delete", "name": "options.unicode"}]}}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode"], "model": [{"key": "options.unicode", "owner": "user", "value": "val"}]}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode"], "model": []}

View File

@ -0,0 +1 @@
{"options.unicode": ["val"]}

View File

@ -0,0 +1 @@
{"cmd": ["config.option('options.unicode').value.set([undefined])", "config.option('options.unicode').value.set(['val'])"], "body": {"updates": [{"action": "modify", "name": "options.unicode", "value": ["val"]}]}}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode"], "model": [{"key": "options.unicode", "owner": "user", "required": true, "value": ["val"]}]}

View File

@ -0,0 +1 @@
{"options.unicode": ["a", "b"]}

View File

@ -0,0 +1 @@
{"options.unicode": ["c", "f", "e"]}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode').value.reset()", "body": {"updates": [{"action": "delete", "name": "options.unicode"}]}}

View File

@ -0,0 +1 @@
{"cmd": "config.option('options.unicode').value.set(['c', 'f', 'e'])", "body": {"updates": [{"action": "modify", "name": "options.unicode", "value": ["c", "f", "e"]}]}}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode"], "model": [{"key": "options.unicode", "owner": "default", "required": true, "value": ["a", "b"]}]}

View File

@ -0,0 +1 @@
{"updates": ["options.unicode"], "model": [{"key": "options.unicode", "owner": "user", "required": true, "value": ["c", "f", "e"]}]}

View File

@ -7,6 +7,7 @@ from os.path import dirname, abspath, join, normpath, splitext
# from tiramisu.error import ValueWarning
from tiramisu_json_api import Config
from tiramisu_json_api.error import PropertiesOptionError
from tiramisu_json_api.setting import undefined
# warnings.simplefilter("always", ValueWarning)
@ -57,8 +58,6 @@ def test_get():
for filename in list_data():
if debug:
print(filename)
if 'master' in filename:
continue
with open(filename, 'r') as fh:
json = loads(fh.read())
config = Config(json)
@ -175,8 +174,6 @@ def test_prop2():
def test_info():
for filename in list_data():
if 'master' in filename:
continue
with open(filename, 'r') as fh:
json = loads(fh.read())
config = Config(json)
@ -189,35 +186,72 @@ def test_info():
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())
debug = True
i = 0
while True:
i += 1
lists = list(list_data('.mod{}'.format(i)))
if not lists:
break
for filename in lists:
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())
if debug:
print(mod['cmd'])
if isinstance(mod['cmd'], list):
for cmd in mod['cmd']:
eval(cmd)
else:
eval(mod['cmd'])
#
if debug:
from pprint import pprint
pprint(data)
config.updates_data(data)
assert dico1 == config.value.dict()
pprint(config.updates)
print('----------------')
pprint(mod['body']['updates'])
assert config.updates == mod['body']['updates']
with open(filename[:-4] + 'dict{}'.format(i), 'r') as fh:
dico1 = loads(fh.read())
if debug:
from pprint import pprint
pprint(dico1)
print('----------------')
pprint(config.value.dict())
assert dico1 == config.value.dict()
def test_mod():
debug = False
# debug = True
i = 0
while True:
i += 1
lists = list(list_data('.mod{}'.format(i)))
if not lists:
break
for filename in lists:
if debug:
print('test_mod', filename)
with open(filename[:-4] + 'json', 'r') as fh:
json = loads(fh.read())
#
config = Config(json)
#
with open(filename[:-4] + 'updates{}'.format(i), 'r') as fh:
data = loads(fh.read())
config.updates_data(data)
with open(filename[:-4] + 'dict{}'.format(i), 'r') as fh:
dico1 = loads(fh.read())
if debug:
from pprint import pprint
pprint(dico1)
print('----------------')
pprint(config.value.dict())
assert dico1 == config.value.dict()