update access to property or permissive in tests

This commit is contained in:
Emmanuel Garette 2018-04-06 08:30:32 +02:00
parent 38890519c9
commit 42fc21e6f5
6 changed files with 35 additions and 35 deletions

View File

@ -143,7 +143,7 @@ def test_multi_with_requires():
assert not 'hidden' in api.option('str').property.get() assert not 'hidden' in api.option('str').property.get()
api.option('int').value.set(1) api.option('int').value.set(1)
raises(PropertiesOptionError, "api.option('str').value.set(['a', 'b'])") raises(PropertiesOptionError, "api.option('str').value.set(['a', 'b'])")
assert 'hidden' in api.option('str').property.get() assert 'hidden' in api.forcepermissive.option('str').property.get()
def test__requires_with_inverted(): def test__requires_with_inverted():
@ -170,7 +170,7 @@ def test_multi_with_requires_in_another_group():
assert not 'hidden' in api.option('opt.str').property.get() assert not 'hidden' in api.option('opt.str').property.get()
api.option('int').value.set(1) api.option('int').value.set(1)
raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])") raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])")
assert 'hidden' in api.option('opt.str').property.get() assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
def test_multi_with_requires_in_another_group_inverse(): def test_multi_with_requires_in_another_group_inverse():
@ -185,7 +185,7 @@ def test_multi_with_requires_in_another_group_inverse():
assert not 'hidden' in api.option('opt.str').property.get() assert not 'hidden' in api.option('opt.str').property.get()
api.option('int').value.set(1) api.option('int').value.set(1)
raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])") raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])")
assert 'hidden' in api.option('opt.str').property.get() assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
def test_apply_requires_from_config(): def test_apply_requires_from_config():
@ -200,7 +200,7 @@ def test_apply_requires_from_config():
assert not 'hidden' in api.option('opt.str').property.get() assert not 'hidden' in api.option('opt.str').property.get()
api.option('int').value.set(1) api.option('int').value.set(1)
raises(PropertiesOptionError, "api.option('opt.str').value.get()") raises(PropertiesOptionError, "api.option('opt.str').value.get()")
assert 'hidden' in api.option('opt.str').property.get() assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
def test_apply_requires_with_disabled(): def test_apply_requires_with_disabled():
@ -215,7 +215,7 @@ def test_apply_requires_with_disabled():
assert not 'disabled' in api.option('opt.str').property.get() assert not 'disabled' in api.option('opt.str').property.get()
api.option('int').value.set(1) api.option('int').value.set(1)
raises(PropertiesOptionError, "api.option('opt.str').value.get()") raises(PropertiesOptionError, "api.option('opt.str').value.get()")
assert 'disabled' in api.option('opt.str').property.get() assert 'disabled' in api.unrestraint.option('opt.str').property.get()
def test_multi_with_requires_with_disabled_in_another_group(): def test_multi_with_requires_with_disabled_in_another_group():
@ -230,7 +230,7 @@ def test_multi_with_requires_with_disabled_in_another_group():
assert not 'disabled' in api.option('opt.str').property.get() assert not 'disabled' in api.option('opt.str').property.get()
api.option('int').value.set(1) api.option('int').value.set(1)
raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])") raises(PropertiesOptionError, "api.option('opt.str').value.set(['a', 'b'])")
assert 'disabled' in api.option('opt.str').property.get() assert 'disabled' in api.unrestraint.option('opt.str').property.get()
def test_multi_with_requires_that_is_multi(): def test_multi_with_requires_that_is_multi():

View File

@ -44,7 +44,7 @@ def test_is_hidden():
descr = make_description() descr = make_description()
api = getapi(Config(descr)) api = getapi(Config(descr))
api.property.read_write() api.property.read_write()
assert not 'frozen' in api.option('gc.dummy').property.get() assert not 'frozen' in api.forcepermissive.option('gc.dummy').property.get()
# setattr # setattr
raises(PropertiesOptionError, "api.option('gc.dummy').value.get() == False") raises(PropertiesOptionError, "api.option('gc.dummy').value.get() == False")
# getattr # getattr
@ -57,10 +57,10 @@ def test_group_is_hidden():
api.property.read_write() api.property.read_write()
api.option('gc').property.add('hidden') api.option('gc').property.add('hidden')
raises(PropertiesOptionError, "api.option('gc.dummy').value.get()") raises(PropertiesOptionError, "api.option('gc.dummy').value.get()")
assert 'hidden' in api.option('gc').property.get() assert 'hidden' in api.forcepermissive.option('gc').property.get()
raises(PropertiesOptionError, "api.option('gc.float').value.get()") raises(PropertiesOptionError, "api.option('gc.float').value.get()")
# manually set the subconfigs to "show" # manually set the subconfigs to "show"
api.option('gc').property.pop('hidden') api.forcepermissive.option('gc').property.pop('hidden')
assert not 'hidden' in api.option('gc').property.get() assert not 'hidden' in api.option('gc').property.get()
assert api.option('gc.float').value.get() == 2.3 assert api.option('gc.float').value.get() == 2.3
#dummy est en hide #dummy est en hide
@ -78,14 +78,14 @@ def test_group_is_hidden_multi():
api.property.read_write() api.property.read_write()
api.option('objspace').property.add('hidden') api.option('objspace').property.add('hidden')
raises(PropertiesOptionError, "api.option('objspace').value.get()") raises(PropertiesOptionError, "api.option('objspace').value.get()")
assert 'hidden' in api.option('objspace').property.get() assert 'hidden' in api.forcepermissive.option('objspace').property.get()
prop = [] prop = []
try: try:
api.option('objspace').value.set(['std']) api.option('objspace').value.set(['std'])
except PropertiesOptionError as err: except PropertiesOptionError as err:
prop = err.proptype prop = err.proptype
assert 'hidden' in prop assert 'hidden' in prop
api.option('objspace').property.pop('hidden') api.forcepermissive.option('objspace').property.pop('hidden')
assert not 'hidden' in api.option('objspace').property.get() assert not 'hidden' in api.option('objspace').property.get()
api.option('objspace').value.set(['std', 'std']) api.option('objspace').value.set(['std', 'std'])
@ -94,8 +94,8 @@ def test_global_show():
descr = make_description() descr = make_description()
api = getapi(Config(descr)) api = getapi(Config(descr))
api.property.read_write() api.property.read_write()
api.option('gc.dummy').property.add('hidden') api.forcepermissive.option('gc.dummy').property.add('hidden')
assert 'hidden' in api.option('gc.dummy').property.get() assert 'hidden' in api.forcepermissive.option('gc.dummy').property.get()
raises(PropertiesOptionError, "api.option('gc.dummy').value.get() == False") raises(PropertiesOptionError, "api.option('gc.dummy').value.get() == False")

View File

@ -536,17 +536,17 @@ def test_values_with_master_disabled():
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0) api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0)
#delete with value in disabled var #delete with value in disabled var
api.option('ip_admin_eth0.netmask_admin_eth0').property.pop('disabled') api.unrestraint.option('ip_admin_eth0.netmask_admin_eth0').property.pop('disabled')
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"]) api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"])
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set("192.168.230.145") api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set("192.168.230.145")
api.option('ip_admin_eth0.netmask_admin_eth0').property.add('disabled') api.unrestraint.option('ip_admin_eth0.netmask_admin_eth0').property.add('disabled')
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0) api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0)
#append with value in disabled var #append with value in disabled var
api.option('ip_admin_eth0.netmask_admin_eth0').property.pop('disabled') api.unrestraint.option('ip_admin_eth0.netmask_admin_eth0').property.pop('disabled')
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"]) api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145"])
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set("192.168.230.145") api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set("192.168.230.145")
api.option('ip_admin_eth0.netmask_admin_eth0').property.add('disabled') api.unrestraint.option('ip_admin_eth0.netmask_admin_eth0').property.add('disabled')
api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145", '192.168.230.43']) api.option('ip_admin_eth0.ip_admin_eth0').value.set(["192.168.230.145", '192.168.230.43'])

View File

@ -26,7 +26,7 @@ def test_permissive():
except PropertiesOptionError as err: except PropertiesOptionError as err:
props = err.proptype props = err.proptype
assert set(props) == {'disabled'} assert set(props) == {'disabled'}
api.permissive.set(frozenset(['disabled'])) api.unrestraint.permissive.set(frozenset(['disabled']))
props = frozenset() props = frozenset()
try: try:
api.option('u1').value.get() api.option('u1').value.get()
@ -57,7 +57,7 @@ def test_permissive_mandatory():
assert frozenset(props) == frozenset(['disabled', 'mandatory']) assert frozenset(props) == frozenset(['disabled', 'mandatory'])
else: else:
assert frozenset(props) == frozenset(['disabled']) assert frozenset(props) == frozenset(['disabled'])
api.permissive.set(frozenset(['mandatory', 'disabled'])) api.unrestraint.permissive.set(frozenset(['mandatory', 'disabled']))
api.property.add('permissive') api.property.add('permissive')
api.option('u1').value.get() api.option('u1').value.get()
api.property.pop('permissive') api.property.pop('permissive')
@ -75,7 +75,7 @@ def test_permissive_frozen():
descr = make_description() descr = make_description()
api = getapi(Config(descr)) api = getapi(Config(descr))
api.property.read_write() api.property.read_write()
api.permissive.set(frozenset(['frozen', 'disabled'])) api.unrestraint.permissive.set(frozenset(['frozen', 'disabled']))
try: try:
api.option('u1').value.set(1) api.option('u1').value.set(1)
except PropertiesOptionError as err: except PropertiesOptionError as err:
@ -103,7 +103,7 @@ if TIRAMISU_VERSION == 3:
descr = make_description() descr = make_description()
api = getapi(Config(descr)) api = getapi(Config(descr))
api.property.read_write() api.property.read_write()
raises(TypeError, "api.permissive.set(['frozen', 'disabled'])") raises(TypeError, "api.unrestraint.permissive.set(['frozen', 'disabled'])")
def test_permissive_option(): def test_permissive_option():
@ -124,7 +124,7 @@ def test_permissive_option():
props = err.proptype props = err.proptype
assert set(props) == {'disabled'} assert set(props) == {'disabled'}
api.option('u1').permissive.set(frozenset(['disabled'])) api.unrestraint.option('u1').permissive.set(frozenset(['disabled']))
props = frozenset() props = frozenset()
try: try:
api.option('u1').value.get() api.option('u1').value.get()
@ -180,7 +180,7 @@ def test_permissive_option_cache():
props = err.proptype props = err.proptype
assert set(props) == {'disabled'} assert set(props) == {'disabled'}
api.option('u1').permissive.set(frozenset(['disabled'])) api.unrestraint.option('u1').permissive.set(frozenset(['disabled']))
props = frozenset() props = frozenset()
try: try:
api.option('u1').value.get() api.option('u1').value.get()
@ -231,7 +231,7 @@ def test_permissive_option_mandatory():
assert frozenset(props) == frozenset(['disabled', 'mandatory']) assert frozenset(props) == frozenset(['disabled', 'mandatory'])
else: else:
assert frozenset(props) == frozenset(['disabled']) assert frozenset(props) == frozenset(['disabled'])
api.option('u1').permissive.set(frozenset(['mandatory', 'disabled'])) api.unrestraint.option('u1').permissive.set(frozenset(['mandatory', 'disabled']))
api.property.add('permissive') api.property.add('permissive')
api.option('u1').value.get() api.option('u1').value.get()
api.property.pop('permissive') api.property.pop('permissive')
@ -249,7 +249,7 @@ def test_permissive_option_frozen():
descr = make_description() descr = make_description()
api = getapi(Config(descr)) api = getapi(Config(descr))
api.property.read_write() api.property.read_write()
api.option('u1').permissive.set(frozenset(['frozen', 'disabled'])) api.unrestraint.option('u1').permissive.set(frozenset(['frozen', 'disabled']))
api.option('u1').value.set(1) api.option('u1').value.set(1)
assert api.option('u1').value.get() == 1 assert api.option('u1').value.get() == 1
api.property.add('permissive') api.property.add('permissive')
@ -263,7 +263,7 @@ if TIRAMISU_VERSION == 3:
descr = make_description() descr = make_description()
api = getapi(Config(descr)) api = getapi(Config(descr))
api.property.read_write() api.property.read_write()
raises(TypeError, "api.option('u1').permissive.set(['frozen', 'disabled'])") raises(TypeError, "api.unrestraint.option('u1').permissive.set(['frozen', 'disabled'])")
def test_remove_option_permissive(): def test_remove_option_permissive():
@ -273,7 +273,7 @@ def test_remove_option_permissive():
api = getapi(Config(rootod)) api = getapi(Config(rootod))
api.property.read_write() api.property.read_write()
raises(PropertiesOptionError, "api.option('od1.var1').value.get()") raises(PropertiesOptionError, "api.option('od1.var1').value.get()")
api.option('od1.var1').permissive.set(frozenset(['hidden'])) api.forcepermissive.option('od1.var1').permissive.set(frozenset(['hidden']))
assert api.option('od1.var1').value.get() == 'value' assert api.option('od1.var1').value.get() == 'value'
api.option('od1.var1').permissive.set(frozenset()) api.forcepermissive.option('od1.var1').permissive.set(frozenset())
raises(PropertiesOptionError, "api.option('od1.var1').value.get()") raises(PropertiesOptionError, "api.option('od1.var1').value.get()")

View File

@ -24,9 +24,9 @@ def test_properties():
except PropertiesOptionError as err: except PropertiesOptionError as err:
props = err.proptype props = err.proptype
assert frozenset(props) == frozenset(['disabled']) assert frozenset(props) == frozenset(['disabled'])
api.option('ip_address_service').property.pop('disabled') api.unrestraint.option('ip_address_service').property.pop('disabled')
api.option('ip_address_service').value.get() api.option('ip_address_service').value.get()
api.option('ip_address_service').property.add('disabled') api.unrestraint.option('ip_address_service').property.add('disabled')
props = [] props = []
try: try:
api.option('ip_address_service').value.get() api.option('ip_address_service').value.get()
@ -34,8 +34,8 @@ def test_properties():
props = err.proptype props = err.proptype
assert frozenset(props) == frozenset(['disabled']) assert frozenset(props) == frozenset(['disabled'])
# pop twice # pop twice
api.option('ip_address_service').property.pop('disabled') api.unrestraint.option('ip_address_service').property.pop('disabled')
api.option('ip_address_service').property.pop('disabled') api.unrestraint.option('ip_address_service').property.pop('disabled')
def test_requires(): def test_requires():
@ -797,7 +797,7 @@ def test_requires_requirement_append():
raises(ValueError, "api.option('ip_address_service').property.add('disabled')") raises(ValueError, "api.option('ip_address_service').property.add('disabled')")
api.option('activate_service').value.set(False) api.option('activate_service').value.set(False)
# disabled is now set, test to remove disabled before store in storage # disabled is now set, test to remove disabled before store in storage
api.option('ip_address_service').property.add("test") api.unrestraint.option('ip_address_service').property.add("test")
def test_requires_different_inverse(): def test_requires_different_inverse():

View File

@ -331,10 +331,10 @@ def test_values_with_master_disabled_submulti():
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0) api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0)
#delete with value in disabled var #delete with value in disabled var
api.option('ip_admin_eth0.netmask_admin_eth0').property.pop('disabled') api.unrestraint.option('ip_admin_eth0.netmask_admin_eth0').property.pop('disabled')
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145']) api.option('ip_admin_eth0.ip_admin_eth0').value.set(['192.168.230.145'])
api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['192.168.230.145']) api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.set(['192.168.230.145'])
api.option('ip_admin_eth0.netmask_admin_eth0').property.add('disabled') api.unrestraint.option('ip_admin_eth0.netmask_admin_eth0').property.add('disabled')
api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0) api.option('ip_admin_eth0.ip_admin_eth0').value.pop(0)