we have to access to option without restriction
This commit is contained in:
parent
d3eef77c03
commit
e73f3d1e47
|
@ -4,6 +4,7 @@ from os import listdir
|
||||||
from os.path import dirname, abspath, join, normpath, splitext, isfile
|
from os.path import dirname, abspath, join, normpath, splitext, isfile
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
import pytest
|
||||||
|
|
||||||
from tiramisu import OptionDescription, Config
|
from tiramisu import OptionDescription, Config
|
||||||
from tiramisu.error import ValueWarning
|
from tiramisu.error import ValueWarning
|
||||||
|
@ -123,7 +124,31 @@ def add_property(expected, prop, prop_value):
|
||||||
return ordered_form
|
return ordered_form
|
||||||
|
|
||||||
|
|
||||||
def test_jsons():
|
|
||||||
|
LISTDATA = list_data()
|
||||||
|
|
||||||
|
|
||||||
|
LISTDATA_MOD = []
|
||||||
|
idx = 0
|
||||||
|
while True:
|
||||||
|
idx += 1
|
||||||
|
list_files = list_data('.mod{}'.format(idx))
|
||||||
|
if not list_files:
|
||||||
|
break
|
||||||
|
LISTDATA_MOD.extend(list_files)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(params=LISTDATA)
|
||||||
|
def filename(request):
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(params=LISTDATA_MOD)
|
||||||
|
def filename_mod(request):
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
|
||||||
|
def test_jsons(filename):
|
||||||
debug = False
|
debug = False
|
||||||
# debug = True
|
# debug = True
|
||||||
datadir = datapath()
|
datadir = datapath()
|
||||||
|
@ -137,8 +162,6 @@ def test_jsons():
|
||||||
for remote in ['minimum', 'none', 'all']:
|
for remote in ['minimum', 'none', 'all']:
|
||||||
if debug:
|
if debug:
|
||||||
print(' ==> remotable', remote)
|
print(' ==> remotable', remote)
|
||||||
filenames = list_data()
|
|
||||||
for filename in filenames:
|
|
||||||
modulepath = splitext(filename)[0]
|
modulepath = splitext(filename)[0]
|
||||||
if debug:
|
if debug:
|
||||||
print(" {} (remote: {}, clearable: {})".format(filename, remote, clearable))
|
print(" {} (remote: {}, clearable: {})".format(filename, remote, clearable))
|
||||||
|
@ -191,14 +214,12 @@ def test_jsons():
|
||||||
assert values == expected, "error in file {}".format(filename)
|
assert values == expected, "error in file {}".format(filename)
|
||||||
|
|
||||||
|
|
||||||
def test_jsons_subconfig():
|
def test_jsons_subconfig(filename):
|
||||||
debug = False
|
debug = False
|
||||||
# debug = True
|
# debug = True
|
||||||
datadir = datapath()
|
datadir = datapath()
|
||||||
if debug:
|
if debug:
|
||||||
print()
|
print()
|
||||||
filenames = list_data()
|
|
||||||
for filename in filenames:
|
|
||||||
modulepath = splitext(filename)[0]
|
modulepath = splitext(filename)[0]
|
||||||
if debug:
|
if debug:
|
||||||
print(" ", filename)
|
print(" ", filename)
|
||||||
|
@ -267,21 +288,15 @@ def test_jsons_subconfig():
|
||||||
assert values == expected, "error in file {}".format(filename)
|
assert values == expected, "error in file {}".format(filename)
|
||||||
|
|
||||||
|
|
||||||
def test_updates():
|
def test_updates(filename_mod):
|
||||||
debug = False
|
debug = False
|
||||||
# debug = True
|
# debug = True
|
||||||
datadir = datapath()
|
datadir = datapath()
|
||||||
idx = 0
|
|
||||||
while True:
|
|
||||||
idx += 1
|
|
||||||
list_files = list_data('.mod{}'.format(idx))
|
|
||||||
if not list_files:
|
|
||||||
break
|
|
||||||
for filename in list_files:
|
|
||||||
if debug:
|
if debug:
|
||||||
print("test/data/" + filename)
|
print("test/data/" + filename_mod)
|
||||||
for issub in [False, True]:
|
for issub in [False, True]:
|
||||||
modulepath = splitext(filename)[0]
|
idx = int(filename_mod[-1])
|
||||||
|
modulepath = splitext(filename_mod)[0]
|
||||||
mod = __import__(modulepath)
|
mod = __import__(modulepath)
|
||||||
descr = mod.get_description()
|
descr = mod.get_description()
|
||||||
if issub:
|
if issub:
|
||||||
|
@ -354,7 +369,7 @@ def test_updates():
|
||||||
with open(join(datadir, modulepath + '.dict'), 'w') as fh:
|
with open(join(datadir, modulepath + '.dict'), 'w') as fh:
|
||||||
dump(config.value.dict(), fh, indent=2)
|
dump(config.value.dict(), fh, indent=2)
|
||||||
else:
|
else:
|
||||||
assert config.value.dict() == dico_ori, "clearable {}, remote: {}, filename: {}".format(clearable, remote, filename)
|
assert config.value.dict() == dico_ori, "clearable {}, remote: {}, filename: {}".format(clearable, remote, filename_mod)
|
||||||
if root is None:
|
if root is None:
|
||||||
suboption = config.option
|
suboption = config.option
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -144,6 +144,7 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
||||||
"""Manage option"""
|
"""Manage option"""
|
||||||
_allow_optiondescription = True
|
_allow_optiondescription = True
|
||||||
_follower_need_index = False
|
_follower_need_index = False
|
||||||
|
_validate_properties = False
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: str,
|
name: str,
|
||||||
|
@ -652,6 +653,7 @@ def _registers(_registers: Dict[str, type],
|
||||||
|
|
||||||
class _TiramisuOption(CommonTiramisu):
|
class _TiramisuOption(CommonTiramisu):
|
||||||
"""Manage selected option"""
|
"""Manage selected option"""
|
||||||
|
_validate_properties = False
|
||||||
_registers = {}
|
_registers = {}
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
name: Optional[str],
|
name: Optional[str],
|
||||||
|
|
|
@ -470,8 +470,8 @@ class TiramisuDict:
|
||||||
self.add_help(schema[path],
|
self.add_help(schema[path],
|
||||||
childapi)
|
childapi)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
import traceback
|
# import traceback
|
||||||
traceback.print_exc()
|
# traceback.print_exc()
|
||||||
if not init:
|
if not init:
|
||||||
raise err
|
raise err
|
||||||
error = err
|
error = err
|
||||||
|
|
Loading…
Reference in New Issue