2013-05-31 23:29:20 +02:00
# coding: utf-8
2017-07-09 09:49:03 +02:00
from . autopath import do_autopath
2015-07-24 17:54:10 +02:00
do_autopath ( )
2019-07-04 20:43:47 +02:00
from . config import config_type , get_config
2015-07-24 17:54:10 +02:00
2013-06-29 18:41:14 +02:00
from copy import copy
2018-04-10 22:42:20 +02:00
from tiramisu . i18n import _
2015-11-29 23:03:08 +01:00
from tiramisu . setting import groups
2013-05-31 23:29:20 +02:00
from tiramisu import setting
setting . expires_time = 1
2018-03-19 08:33:53 +01:00
from tiramisu import IPOption , OptionDescription , BoolOption , IntOption , StrOption , \
2019-03-13 08:49:18 +01:00
Leadership , Config , calc_value , Params , ParamOption
2019-07-04 20:43:47 +02:00
from tiramisu . error import PropertiesOptionError , RequirementError , ConfigError
2013-05-31 23:29:20 +02:00
from py . test import raises
2018-10-31 08:00:19 +01:00
from tiramisu . storage import list_sessions , delete_session
def teardown_function ( function ) :
assert list_sessions ( ) == [ ] , ' session list is not empty when leaving " {} " ' . format ( function . __name__ )
2013-05-31 23:29:20 +02:00
2019-07-04 20:43:47 +02:00
def test_properties ( config_type ) :
2018-04-05 19:06:38 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' , properties = ( ' disabled ' , ) )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg_ori = Config ( od )
cfg_ori . property . read_write ( )
cfg = get_config ( cfg_ori , config_type )
2018-04-05 19:06:38 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2018-04-05 19:06:38 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
cfg . send ( )
cfg_ori . unrestraint . option ( ' ip_address_service ' ) . property . pop ( ' disabled ' )
cfg = get_config ( cfg_ori , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
if config_type == ' tiramisu-api ' :
cfg . send ( )
cfg_ori . unrestraint . option ( ' ip_address_service ' ) . property . add ( ' disabled ' )
cfg = get_config ( cfg_ori , config_type )
2018-04-05 19:06:38 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2018-04-05 19:06:38 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
# pop twice
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
cfg . send ( )
cfg_ori . unrestraint . option ( ' ip_address_service ' ) . property . pop ( ' disabled ' )
cfg_ori . unrestraint . option ( ' ip_address_service ' ) . property . pop ( ' disabled ' )
2018-04-05 19:06:38 +02:00
2019-07-04 20:43:47 +02:00
def test_requires ( config_type ) :
2013-05-31 23:29:20 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
2013-05-31 23:29:20 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
assert not cfg . option ( ' activate_service ' ) . option . requires ( )
assert cfg . option ( ' ip_address_service ' ) . option . requires ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-05-31 23:29:20 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-05-31 23:29:20 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2014-02-04 21:40:07 +01:00
2019-07-04 20:43:47 +02:00
def test_requires_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( a ) ) , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
assert not cfg . option ( ' activate_service ' ) . option . requires ( )
assert cfg . option ( ' ip_address_service ' ) . option . requires ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2019-03-13 08:49:18 +01:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
def test_requires_inverse ( config_type ) :
2018-08-04 23:08:02 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' , ' inverse ' : True } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2018-08-04 23:08:02 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2018-08-04 23:08:02 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( True )
2018-08-04 23:08:02 +02:00
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2018-08-04 23:08:02 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
def test_requires_self ( config_type ) :
2018-04-25 19:12:54 +02:00
a = StrOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : ' self ' , ' expected ' : ' b ' , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . option ( ' ip_address_service ' ) . value . get ( ) == None
cfg . option ( ' ip_address_service ' ) . value . set ( ' a ' )
assert cfg . option ( ' ip_address_service ' ) . value . get ( ) == ' a '
cfg . option ( ' ip_address_service ' ) . value . set ( ' b ' )
2018-04-25 19:12:54 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2018-04-25 19:12:54 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
def test_requires_with_requires ( config_type ) :
2014-02-04 21:40:07 +01:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg . option ( ' ip_address_service ' ) . property . add ( ' test ' )
cfg = get_config ( cfg , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2014-02-04 21:40:07 +01:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2014-02-04 21:40:07 +01:00
except PropertiesOptionError as err :
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-05-31 23:29:20 +02:00
2013-12-09 18:56:29 +01:00
def test_requires_invalid ( ) :
a = BoolOption ( ' activate_service ' , ' ' , True )
2015-11-29 23:03:08 +01:00
a
2013-12-09 18:56:29 +01:00
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires= ' string ' ) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' expected ' : False, ' action ' : ' disabled ' , ' unknown ' : True}]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' expected ' : False}]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' action ' : ' disabled ' }]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' expected ' : False, ' action ' : ' disabled ' }]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' expected ' : False, ' action ' : ' disabled ' , ' inverse ' : ' string ' }]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' expected ' : False, ' action ' : ' disabled ' , ' transitive ' : ' string ' }]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' expected ' : False, ' action ' : ' disabled ' , ' same_action ' : ' string ' }]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : ' string ' , ' expected ' : False, ' action ' : ' disabled ' }]) " )
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , requires=[ { ' option ' : a, ' expected ' : ' string ' , ' action ' : ' disabled ' }]) " )
2019-07-04 20:43:47 +02:00
def test_requires_same_action ( config_type ) :
2018-04-10 22:42:20 +02:00
activate_service = BoolOption ( ' activate_service ' , ' ' , True )
activate_service_web = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' option ' : activate_service , ' expected ' : False ,
' action ' : ' new ' } ] )
2013-06-13 14:43:51 +02:00
2018-04-10 22:42:20 +02:00
ip_address_service_web = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : activate_service_web , ' expected ' : False ,
' action ' : ' disabled ' , ' inverse ' : False ,
' transitive ' : True , ' same_action ' : False } ] )
od1 = OptionDescription ( ' service ' , ' ' , [ activate_service , activate_service_web , ip_address_service_web ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od1 )
cfg . property . read_write ( )
cfg . property . add ( ' new ' )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-06-13 14:43:51 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-13 14:43:51 +02:00
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert frozenset ( props ) == frozenset ( [ ' new ' ] )
else :
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-13 14:43:51 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-13 14:43:51 +02:00
props = err . proptype
2018-04-10 22:42:20 +02:00
submsg = ' " disabled " ( ' + _ ( ' the value of " {0} " is {1} ' ) . format ( ' activate_service ' , ' " False " ' ) + ' ) '
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert str ( err ) == str ( _ ( ' cannot access to {0} " {1} " because has {2} {3} ' ) . format ( ' option ' , ' ip_address_service_web ' , _ ( ' property ' ) , submsg ) )
#access to cache
assert str ( err ) == str ( _ ( ' cannot access to {0} " {1} " because has {2} {3} ' ) . format ( ' option ' , ' ip_address_service_web ' , _ ( ' property ' ) , submsg ) )
else :
# FIXME
assert str ( err ) == ' error '
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-13 14:43:51 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_same_action_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
activate_service = BoolOption ( ' activate_service ' , ' ' , True )
activate_service_web = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( activate_service ) ) , ' expected ' : False ,
' action ' : ' new ' } ] )
ip_address_service_web = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : activate_service_web , ' expected ' : False ,
' action ' : ' disabled ' , ' inverse ' : False ,
' transitive ' : True , ' same_action ' : False } ] )
od1 = OptionDescription ( ' service ' , ' ' , [ activate_service , activate_service_web , ip_address_service_web ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od1 )
cfg . property . read_write ( )
cfg . property . add ( ' new ' )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2019-03-13 08:49:18 +01:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert frozenset ( props ) == frozenset ( [ ' new ' ] )
else :
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-03-13 08:49:18 +01:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
submsg = ' " disabled " ( ' + _ ( ' the calculated value is {0} ' ) . format ( ' " False " ' ) + ' ) '
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert str ( err ) == str ( _ ( ' cannot access to {0} " {1} " because has {2} {3} ' ) . format ( ' option ' , ' ip_address_service_web ' , _ ( ' property ' ) , submsg ) )
#access to cache
assert str ( err ) == str ( _ ( ' cannot access to {0} " {1} " because has {2} {3} ' ) . format ( ' option ' , ' ip_address_service_web ' , _ ( ' property ' ) , submsg ) )
else :
# FIXME
assert str ( err ) == ' error '
2019-03-13 08:49:18 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
def test_multiple_requires ( config_type ) :
2013-07-03 15:04:15 +02:00
a = StrOption ( ' activate_service ' , ' ' )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : ' yes ' , ' action ' : ' disabled ' } ,
{ ' option ' : a , ' expected ' : ' ok ' , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( ' yes ' )
2013-07-03 15:04:15 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-07-03 15:04:15 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' ok ' )
2013-07-03 15:04:15 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-07-03 15:04:15 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' no ' )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
def test_multiple_requires_cumulative ( config_type ) :
2013-09-02 17:13:07 +02:00
a = StrOption ( ' activate_service ' , ' ' )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : ' yes ' , ' action ' : ' disabled ' } ,
{ ' option ' : a , ' expected ' : ' yes ' , ' action ' : ' hidden ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( ' yes ' )
2013-09-02 17:13:07 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-09-02 17:13:07 +02:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert set ( props ) == { ' hidden ' , ' disabled ' }
else :
assert set ( props ) == { ' disabled ' }
2013-09-02 17:13:07 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' ok ' )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-09-02 17:13:07 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' no ' )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-09-02 17:13:07 +02:00
2019-07-04 20:43:47 +02:00
def test_multiple_requires_cumulative_inverse ( config_type ) :
2013-09-02 19:47:00 +02:00
a = StrOption ( ' activate_service ' , ' ' )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : ' yes ' , ' action ' : ' disabled ' , ' inverse ' : True } ,
{ ' option ' : a , ' expected ' : ' yes ' , ' action ' : ' hidden ' , ' inverse ' : True } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-09-02 19:47:00 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-09-02 19:47:00 +02:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert set ( props ) == { ' hidden ' , ' disabled ' }
else :
assert set ( props ) == { ' disabled ' }
cfg . option ( ' activate_service ' ) . value . set ( ' yes ' )
cfg . option ( ' ip_address_service ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( ' ok ' )
2013-09-02 19:47:00 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-09-02 19:47:00 +02:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert set ( props ) == { ' hidden ' , ' disabled ' }
else :
assert set ( props ) == { ' disabled ' }
2013-09-02 19:47:00 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' no ' )
2013-09-02 19:47:00 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-09-02 19:47:00 +02:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu ' :
assert set ( props ) == { ' hidden ' , ' disabled ' }
else :
assert set ( props ) == { ' disabled ' }
2013-09-02 19:47:00 +02:00
2019-07-04 20:43:47 +02:00
def test_multiple_requires_inverse ( config_type ) :
2013-07-03 15:04:15 +02:00
a = StrOption ( ' activate_service ' , ' ' )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : ' yes ' , ' action ' : ' disabled ' , ' inverse ' : True } ,
{ ' option ' : a , ' expected ' : ' ok ' , ' action ' : ' disabled ' , ' inverse ' : True } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-07-03 15:04:15 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-07-03 15:04:15 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' yes ' )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' ok ' )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( ' no ' )
2013-07-03 15:04:15 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-07-03 15:04:15 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-07-03 15:04:15 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_transitive ( config_type ) :
2013-05-31 23:29:20 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
2013-06-10 15:19:00 +02:00
2013-05-31 23:29:20 +02:00
d = IPOption ( ' ip_address_service_web ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : b , ' expected ' : False , ' action ' : ' disabled ' } ] )
2013-05-31 23:29:20 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-05-31 23:29:20 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-05-31 23:29:20 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-05-31 23:29:20 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-05-31 23:29:20 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-05-31 23:29:20 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_transitive_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( a ) ) , ' expected ' : False , ' action ' : ' disabled ' } ] )
d = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( b ) ) , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2019-03-13 08:49:18 +01:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
def test_requires_transitive_unrestraint ( config_type ) :
2018-12-24 09:30:58 +01:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
d = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : b , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg_ori = Config ( od )
cfg_ori . property . read_write ( )
cfg = get_config ( cfg_ori , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2018-12-24 09:30:58 +01:00
#
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
cfg . send ( )
assert cfg_ori . unrestraint . option ( ' activate_service_web ' ) . property . get ( ) == { ' disabled ' }
assert cfg_ori . unrestraint . option ( ' ip_address_service_web ' ) . property . get ( ) == { ' disabled ' }
2018-12-24 09:30:58 +01:00
2019-07-04 20:43:47 +02:00
def test_requires_transitive_owner ( config_type ) :
2014-04-12 11:53:58 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
d = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : b , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2014-04-12 11:53:58 +02:00
#no more default value
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . set ( ' 1.1.1.1 ' )
cfg . option ( ' activate_service ' ) . value . set ( False )
2014-04-12 11:53:58 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2014-04-12 11:53:58 +02:00
except PropertiesOptionError as err :
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2014-04-12 11:53:58 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_transitive_bis ( config_type ) :
2013-06-10 15:19:00 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
abis = BoolOption ( ' activate_service_bis ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : True , ' action ' : ' disabled ' , ' inverse ' : True } ] )
2013-06-10 15:19:00 +02:00
d = IPOption ( ' ip_address_service_web ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : b , ' expected ' : True , ' action ' : ' disabled ' , ' inverse ' : True } ] )
2013-06-10 15:19:00 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , abis , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-06-10 15:19:00 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-06-10 15:19:00 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-10 15:19:00 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-10 15:19:00 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-10 15:19:00 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-10 15:19:00 +02:00
2018-03-31 21:17:37 +02:00
def test_requires_transitive_hidden_permissive ( ) :
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' hidden ' } ] )
d = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : b , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
# FIXME permissive cfg = get_config(cfg, config_type)
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2018-03-31 21:17:37 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2018-03-31 21:17:37 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_transitive_hidden_disabled ( config_type ) :
2013-05-31 23:29:20 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' hidden ' } ] )
2013-05-31 23:29:20 +02:00
d = IPOption ( ' ip_address_service_web ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : b , ' expected ' : False , ' action ' : ' disabled ' } ] )
2013-05-31 23:29:20 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-05-31 23:29:20 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-05-31 23:29:20 +02:00
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
else :
assert frozenset ( props ) == frozenset ( [ ' hidden ' ] )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2013-05-31 23:29:20 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_transitive_hidden_disabled_multiple ( config_type ) :
2017-07-21 18:03:34 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' hidden ' } ,
{ ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
d = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : b , ' expected ' : False , ' action ' : ' mandatory ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg_ori = Config ( od )
cfg_ori . property . read_write ( )
cfg = get_config ( cfg_ori , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2018-04-11 08:40:59 +02:00
req = None
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
try :
cfg . option ( ' activate_service ' ) . value . set ( False )
except ConfigError as err :
req = err
error_msg = str ( _ ( ' unable to transform tiramisu object to dict: {} ' ) . format ( _ ( ' cannot access to option " {0} " because required option " {1} " has {2} {3} ' ) . format ( ' ip_address_service_web ' , ' activate_service_web ' , _ ( ' property ' ) , ' " disabled " ' ) ) )
else :
cfg . option ( ' activate_service ' ) . value . set ( False )
#
props = [ ]
try :
cfg . option ( ' activate_service_web ' ) . value . get ( )
except PropertiesOptionError as err :
props = err . proptype
if config_type == ' tiramisu-api ' :
assert set ( props ) == { ' disabled ' , }
else :
assert set ( props ) == { ' disabled ' , ' hidden ' }
del props
#
try :
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
except RequirementError as err :
req = err
error_msg = str ( _ ( ' cannot access to option " {0} " because required option " {1} " has {2} {3} ' ) . format ( ' ip_address_service_web ' , ' activate_service_web ' , _ ( ' property ' ) , ' " disabled " ' ) )
2018-04-11 08:40:59 +02:00
assert req , " ip_address_service_web should raise RequirementError "
2019-07-04 20:43:47 +02:00
assert str ( req ) == error_msg
2018-10-31 08:00:19 +01:00
del req
#
2019-07-04 20:43:47 +02:00
cfg_ori . permissive . set ( frozenset ( ) )
if config_type == ' tiramisu-api ' :
try :
cfg = get_config ( cfg_ori , config_type )
except ConfigError as err :
req = err
error_msg = str ( _ ( ' unable to transform tiramisu object to dict: {} ' ) . format ( _ ( ' cannot access to option " {0} " because required option " {1} " has {2} {3} ' ) . format ( ' ip_address_service_web ' , ' activate_service_web ' , _ ( ' properties ' ) , ' " disabled " {} " hidden " ' . format ( _ ( ' and ' ) ) ) ) )
else :
cfg = get_config ( cfg_ori , config_type )
try :
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
except RequirementError as err :
req = err
error_msg = str ( _ ( ' cannot access to option " {0} " because required option " {1} " has {2} {3} ' ) . format ( ' ip_address_service_web ' , ' activate_service_web ' , _ ( ' properties ' ) , ' " disabled " {} " hidden " ' . format ( _ ( ' and ' ) ) ) )
2018-04-11 08:40:59 +02:00
assert req , " ip_address_service_web should raise RequirementError "
2019-07-04 20:43:47 +02:00
assert str ( req ) == error_msg
2018-10-31 08:00:19 +01:00
del req
2017-07-21 18:03:34 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_not_transitive ( config_type ) :
2013-05-31 23:29:20 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
2013-05-31 23:29:20 +02:00
d = IPOption ( ' ip_address_service_web ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : b , ' expected ' : False ,
' action ' : ' disabled ' , ' transitive ' : False } ] )
2013-05-31 23:29:20 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-05-31 23:29:20 +02:00
#
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service_web ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-05-31 23:29:20 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-05-31 23:29:20 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
2013-06-13 12:15:46 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_not_transitive_not_same_action ( config_type ) :
2016-10-12 22:17:04 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' activate_service_web ' , ' ' , True ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
d = IPOption ( ' ip_address_service_web ' , ' ' ,
requires = [ { ' option ' : b , ' expected ' : False ,
' action ' : ' hidden ' , ' transitive ' : False } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , d ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' activate_service ' ) . value . get ( )
cfg . option ( ' activate_service_web ' ) . value . get ( )
cfg . option ( ' ip_address_service_web ' ) . value . get ( )
if config_type == ' tiramisu-api ' :
raises ( ConfigError , " cfg.option( ' activate_service ' ).value.set(False) " )
else :
cfg . option ( ' activate_service ' ) . value . set ( False )
#
props = [ ]
try :
cfg . option ( ' activate_service_web ' ) . value . get ( )
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
#
raises ( RequirementError , " cfg.option( ' ip_address_service_web ' ).value.get() " )
2016-10-12 22:17:04 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_None ( config_type ) :
2013-06-13 12:15:46 +02:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IPOption ( ' ip_address_service ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : None , ' action ' : ' disabled ' } ] )
2013-06-13 12:15:46 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-06-13 12:15:46 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-13 12:15:46 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled ( config_type ) :
2013-06-28 11:59:51 +02:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
c = IPOption ( ' ip_address_service ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : True , ' action ' : ' disabled ' } ,
{ ' option ' : b , ' expected ' : 1 , ' action ' : ' disabled ' } ] )
2013-06-28 11:59:51 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b , c ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' num_service ' ) . value . set ( 1 )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2013-06-29 18:41:14 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
c = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( a ) ) , ' expected ' : True , ' action ' : ' disabled ' } ,
{ ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( b ) ) , ' expected ' : 1 , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , c ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2019-03-13 08:49:18 +01:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' num_service ' ) . value . set ( 1 )
2019-03-13 08:49:18 +01:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2019-03-13 08:49:18 +01:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2019-03-13 08:49:18 +01:00
except PropertiesOptionError as err :
props = err . proptype
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_new_format ( config_type ) :
2017-05-20 16:28:19 +02:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
c = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' expected ' : [ { ' option ' : a , ' value ' : True } , { ' option ' : b , ' value ' : 1 } ] , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , c ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' num_service ' ) . value . set ( 1 )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2017-05-20 16:28:19 +02:00
2017-07-21 22:34:41 +02:00
def test_requires_unknown_operator ( ) :
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
raises ( ValueError , """ IPOption( ' ip_address_service ' , ' ' ,
requires = [ { ' expected ' : [ { ' option ' : a , ' value ' : True } , { ' option ' : b , ' value ' : 1 } ] ,
' action ' : ' disabled ' , ' operator ' : ' unknown ' } ] ) """ )
def test_requires_keys ( ) :
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
raises ( ValueError , """ IPOption( ' ip_address_service ' , ' ' ,
requires = [ { ' expected ' : [ { ' option ' : a , ' value2 ' : True } , { ' option ' : b , ' value ' : 1 } ] ,
' action ' : ' disabled ' , ' operator ' : ' and ' } ] ) """ )
def test_requires_unvalid ( ) :
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
raises ( ValueError , """ IPOption( ' ip_address_service ' , ' ' ,
requires = [ { ' expected ' : [ { ' option ' : a , ' value ' : ' unvalid ' } , { ' option ' : b , ' value ' : 1 } ] ,
' action ' : ' disabled ' , ' operator ' : ' and ' } ] ) """ )
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_new_format_and ( config_type ) :
2017-05-20 16:28:19 +02:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
c = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' expected ' : [ { ' option ' : a , ' value ' : True } , { ' option ' : b , ' value ' : 1 } ] , ' action ' : ' disabled ' , ' operator ' : ' and ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , c ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert props == [ ]
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' num_service ' ) . value . set ( 1 )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert props == [ ]
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_new_format_and_2 ( config_type ) :
2017-05-20 16:28:19 +02:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
c = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' expected ' : [ { ' option ' : a , ' value ' : True } , { ' option ' : b , ' value ' : 1 } ] , ' action ' : ' disabled ' , ' operator ' : ' and ' } ,
{ ' expected ' : [ { ' option ' : a , ' value ' : False } , { ' option ' : b , ' value ' : 1 } ] , ' action ' : ' expert ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b , c ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . add ( ' expert ' )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
assert props == [ ]
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
cfg . option ( ' num_service ' ) . value . set ( 1 )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
else :
assert frozenset ( props ) == frozenset ( [ ' expert ' ] )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2017-05-20 16:28:19 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2017-05-20 16:28:19 +02:00
except PropertiesOptionError as err :
props = err . proptype
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
else :
assert frozenset ( props ) == frozenset ( [ ' disabled ' , ' expert ' ] )
2017-05-20 16:28:19 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_inverse ( config_type ) :
2013-06-28 11:59:51 +02:00
a = BoolOption ( ' activate_service ' , ' ' )
b = IntOption ( ' num_service ' , ' ' )
c = IPOption ( ' ip_address_service ' , ' ' ,
2013-06-29 18:41:14 +02:00
requires = [ { ' option ' : a , ' expected ' : True ,
' action ' : ' disabled ' , ' inverse ' : True } ,
{ ' option ' : b , ' expected ' : 1 ,
' action ' : ' disabled ' , ' inverse ' : True } ] )
2013-06-28 11:59:51 +02:00
od = OptionDescription ( ' service ' , ' ' , [ a , b , c ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' num_service ' ) . value . set ( 1 )
2013-06-28 11:59:51 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-28 11:59:51 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-28 11:59:51 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate_service ' ) . value . set ( True )
cfg . option ( ' ip_address_service ' ) . value . get ( )
2013-06-29 18:41:14 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_2 ( config_type ) :
2013-06-29 18:41:14 +02:00
a = BoolOption ( ' a ' , ' ' )
b = BoolOption ( ' b ' , ' ' )
c = BoolOption ( ' c ' , ' ' )
d = BoolOption ( ' d ' , ' ' )
e = BoolOption ( ' e ' , ' ' )
f = BoolOption ( ' f ' , ' ' )
g = BoolOption ( ' g ' , ' ' )
h = BoolOption ( ' h ' , ' ' )
i = BoolOption ( ' i ' , ' ' )
j = BoolOption ( ' j ' , ' ' )
k = BoolOption ( ' k ' , ' ' )
l = BoolOption ( ' l ' , ' ' )
m = BoolOption ( ' m ' , ' ' )
list_bools = [ a , b , c , d , e , f , g , h , i , j , k , l , m ]
requires = [ ]
for boo in list_bools :
requires . append ( { ' option ' : boo , ' expected ' : True , ' action ' : ' disabled ' } )
z = IPOption ( ' z ' , ' ' , requires = requires )
y = copy ( list_bools )
y . append ( z )
od = OptionDescription ( ' service ' , ' ' , y )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-06-29 18:41:14 +02:00
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-06-29 18:41:14 +02:00
for boo in list_bools :
2019-07-04 20:43:47 +02:00
cfg . option ( boo . impl_getname ( ) ) . value . set ( True )
2013-06-29 18:41:14 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-29 18:41:14 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-29 18:41:14 +02:00
for boo in list_bools :
2019-07-04 20:43:47 +02:00
cfg . option ( boo . impl_getname ( ) ) . value . set ( False )
2013-06-29 18:41:14 +02:00
if boo == m :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-06-29 18:41:14 +02:00
else :
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-29 18:41:14 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-29 18:41:14 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_multi_disabled_inverse_2 ( config_type ) :
2013-06-29 18:41:14 +02:00
a = BoolOption ( ' a ' , ' ' )
b = BoolOption ( ' b ' , ' ' )
c = BoolOption ( ' c ' , ' ' )
d = BoolOption ( ' d ' , ' ' )
e = BoolOption ( ' e ' , ' ' )
f = BoolOption ( ' f ' , ' ' )
g = BoolOption ( ' g ' , ' ' )
h = BoolOption ( ' h ' , ' ' )
i = BoolOption ( ' i ' , ' ' )
j = BoolOption ( ' j ' , ' ' )
k = BoolOption ( ' k ' , ' ' )
l = BoolOption ( ' l ' , ' ' )
m = BoolOption ( ' m ' , ' ' )
list_bools = [ a , b , c , d , e , f , g , h , i , j , k , l , m ]
requires = [ ]
for boo in list_bools :
requires . append ( { ' option ' : boo , ' expected ' : True , ' action ' : ' disabled ' ,
' inverse ' : True } )
z = IPOption ( ' z ' , ' ' , requires = requires )
y = copy ( list_bools )
y . append ( z )
od = OptionDescription ( ' service ' , ' ' , y )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2013-06-29 18:41:14 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-29 18:41:14 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-29 18:41:14 +02:00
for boo in list_bools :
2019-07-04 20:43:47 +02:00
cfg . option ( boo . impl_getname ( ) ) . value . set ( True )
2013-06-29 18:41:14 +02:00
if boo == m :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-06-29 18:41:14 +02:00
else :
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-29 18:41:14 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-06-29 18:41:14 +02:00
for boo in list_bools :
2019-07-04 20:43:47 +02:00
cfg . option ( boo . impl_getname ( ) ) . value . set ( False )
2013-06-29 18:41:14 +02:00
props = [ ]
try :
2019-07-04 20:43:47 +02:00
cfg . option ( ' z ' ) . value . get ( )
2013-08-28 11:33:43 +02:00
except PropertiesOptionError as err :
2013-06-29 18:41:14 +02:00
props = err . proptype
2018-03-19 08:33:53 +01:00
assert frozenset ( props ) == frozenset ( [ ' disabled ' ] )
2013-08-22 22:46:02 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_requirement_append ( config_type ) :
2013-08-22 22:46:02 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg_ori = Config ( od )
cfg_ori . property . read_write ( )
cfg = get_config ( cfg_ori , config_type )
cfg . property . get ( )
cfg . option ( ' ip_address_service ' ) . property . get ( )
if config_type == ' tiramisu-api ' :
cfg . send ( )
raises ( ValueError , " cfg_ori.option( ' ip_address_service ' ).property.add( ' disabled ' ) " )
cfg = get_config ( cfg_ori , config_type )
cfg . option ( ' activate_service ' ) . value . set ( False )
2013-08-24 16:30:46 +02:00
# disabled is now set, test to remove disabled before store in storage
2019-07-04 20:43:47 +02:00
if config_type == ' tiramisu-api ' :
cfg . send ( )
cfg_ori . unrestraint . option ( ' ip_address_service ' ) . property . add ( " test " )
2013-08-22 22:57:32 +02:00
2019-07-04 20:43:47 +02:00
def test_requires_different_inverse ( config_type ) :
2013-12-09 18:56:29 +01:00
a = BoolOption ( ' activate_service ' , ' ' , True )
2017-01-12 19:52:03 +01:00
b = IPOption ( ' ip_address_service ' , ' ' , requires = [
{ ' option ' : a , ' expected ' : True , ' action ' : ' disabled ' , ' inverse ' : True } ,
{ ' option ' : a , ' expected ' : True , ' action ' : ' disabled ' , ' inverse ' : False } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
raises ( PropertiesOptionError , " cfg.option( ' ip_address_service ' ).value.get() " )
cfg . option ( ' activate_service ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_address_service ' ).value.get() " )
2017-01-12 19:52:03 +01:00
2019-07-04 20:43:47 +02:00
def test_requires_different_inverse_unicode ( config_type ) :
2017-01-12 19:52:03 +01:00
a = BoolOption ( ' activate_service ' , ' ' , True )
d = StrOption ( ' activate_other_service ' , ' ' , ' val2 ' )
b = IPOption ( ' ip_address_service ' , ' ' , requires = [
{ ' option ' : a , ' expected ' : True , ' action ' : ' disabled ' , ' inverse ' : True } ,
{ ' option ' : d , ' expected ' : ' val1 ' , ' action ' : ' disabled ' , ' inverse ' : False } ] )
od = OptionDescription ( ' service ' , ' ' , [ a , d , b ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . option ( ' ip_address_service ' ) . value . get ( ) == None
cfg . option ( ' activate_service ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_address_service ' ).value.get() " )
cfg . option ( ' activate_service ' ) . value . set ( True )
assert cfg . option ( ' ip_address_service ' ) . value . get ( ) == None
cfg . option ( ' activate_other_service ' ) . value . set ( ' val1 ' )
raises ( PropertiesOptionError , " cfg.option( ' ip_address_service ' ).value.get() " )
cfg . option ( ' activate_service ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_address_service ' ).value.get() " )
def test_requires_recursive_path ( config_type ) :
2013-08-22 22:57:32 +02:00
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' ,
requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
od1 = OptionDescription ( ' service ' , ' ' , [ a , b ] , requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
od = OptionDescription ( ' base ' , ' ' , [ od1 ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( od )
cfg . property . read_write ( )
if config_type == ' tiramisu-api ' :
raises ( ConfigError , " get_config(cfg, config_type) " )
else :
cfg = get_config ( cfg , config_type )
raises ( RequirementError , " cfg.option( ' service.a ' ).value.get() " )
2013-09-02 19:47:00 +02:00
2015-12-22 22:06:14 +01:00
def test_optiondescription_requires ( ) :
a = BoolOption ( ' activate_service ' , ' ' , True )
b = BoolOption ( ' ip_address_service ' , ' ' , multi = True )
a , b
OptionDescription ( ' service ' , ' ' , [ b ] , requires = [ { ' option ' : a , ' expected ' : False , ' action ' : ' disabled ' } ] )
def test_optiondescription_requires_multi ( ) :
a = BoolOption ( ' activate_service ' , ' ' , True )
b = IPOption ( ' ip_address_service ' , ' ' , multi = True )
a , b
raises ( ValueError , " OptionDescription( ' service ' , ' ' , [a], requires=[ { ' option ' : b, ' expected ' : False, ' action ' : ' disabled ' }]) " )
2013-09-02 19:47:00 +02:00
def test_properties_conflict ( ) :
a = BoolOption ( ' activate_service ' , ' ' , True )
2015-11-29 23:03:08 +01:00
a
2013-09-02 19:47:00 +02:00
raises ( ValueError , " IPOption( ' ip_address_service ' , ' ' , properties=( ' disabled ' ,), requires=[ { ' option ' : a, ' expected ' : False, ' action ' : ' disabled ' }]) " )
raises ( ValueError , " od1 = OptionDescription( ' service ' , ' ' , [a], properties=( ' disabled ' ,), requires=[ { ' option ' : a, ' expected ' : False, ' action ' : ' disabled ' }]) " )
2015-11-29 23:03:08 +01:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires ( config_type ) :
2015-11-29 23:03:08 +01:00
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' option ' : ip_admin_eth0 , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
2019-02-23 19:06:23 +01:00
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
2018-03-19 08:33:53 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
2018-03-19 08:33:53 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) is None
cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . set ( ' 255.255.255.255 ' )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) == ' 255.255.255.255 '
assert cfg . value . dict ( ) == { ' ip_admin_eth0.ip_admin_eth0 ' : [ ' 192.168.1.2 ' , ' 192.168.1.2 ' ] ,
2018-10-31 08:00:19 +01:00
' ip_admin_eth0.netmask_admin_eth0 ' : [ None , ' 255.255.255.255 ' ] }
2018-03-19 08:33:53 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
ret = cfg . value . dict ( )
2018-08-19 15:19:42 +02:00
assert set ( ret . keys ( ) ) == set ( [ ' ip_admin_eth0.ip_admin_eth0 ' , ' ip_admin_eth0.netmask_admin_eth0 ' ] )
assert ret [ ' ip_admin_eth0.ip_admin_eth0 ' ] == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
assert len ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] ) == 2
2018-10-31 08:00:19 +01:00
assert ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ] is None
2018-08-19 15:19:42 +02:00
assert isinstance ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ] , PropertiesOptionError )
2018-10-31 08:00:19 +01:00
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ]
2018-08-19 15:19:42 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . set ( ' 255.255.255.255 ' )
ret = cfg . value . dict ( )
2018-08-19 15:19:42 +02:00
assert set ( ret . keys ( ) ) == set ( [ ' ip_admin_eth0.ip_admin_eth0 ' , ' ip_admin_eth0.netmask_admin_eth0 ' ] )
assert ret [ ' ip_admin_eth0.ip_admin_eth0 ' ] == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
assert len ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] ) == 2
assert ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ] == ' 255.255.255.255 '
assert isinstance ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ] , PropertiesOptionError )
2018-10-31 08:00:19 +01:00
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ]
2015-11-30 15:55:34 +01:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( ip_admin_eth0 ) ) , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) is None
cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . set ( ' 255.255.255.255 ' )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) == ' 255.255.255.255 '
assert cfg . value . dict ( ) == { ' ip_admin_eth0.ip_admin_eth0 ' : [ ' 192.168.1.2 ' , ' 192.168.1.2 ' ] ,
2019-03-13 08:49:18 +01:00
' ip_admin_eth0.netmask_admin_eth0 ' : [ None , ' 255.255.255.255 ' ] }
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
ret = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert set ( ret . keys ( ) ) == set ( [ ' ip_admin_eth0.ip_admin_eth0 ' , ' ip_admin_eth0.netmask_admin_eth0 ' ] )
assert ret [ ' ip_admin_eth0.ip_admin_eth0 ' ] == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
assert len ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] ) == 2
assert ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ] is None
assert isinstance ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ] , PropertiesOptionError )
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ]
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . set ( ' 255.255.255.255 ' )
ret = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert set ( ret . keys ( ) ) == set ( [ ' ip_admin_eth0.ip_admin_eth0 ' , ' ip_admin_eth0.netmask_admin_eth0 ' ] )
assert ret [ ' ip_admin_eth0.ip_admin_eth0 ' ] == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
assert len ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] ) == 2
assert ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ] == ' 255.255.255.255 '
assert isinstance ( ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ] , PropertiesOptionError )
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ]
del ret [ ' ip_admin_eth0.netmask_admin_eth0 ' ]
2019-02-23 19:06:23 +01:00
def test_leadership_requires_both ( ) :
2018-09-29 21:37:39 +02:00
ip_admin = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True ,
requires = [ { ' option ' : ip_admin , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True )
2019-02-23 19:06:23 +01:00
raises ( RequirementError , " Leadership( ' ip_admin_eth0 ' , ' ' , [ip_admin_eth0, netmask_admin_eth0], requires=[ { ' option ' : ip_admin, ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' }]) " )
2018-09-29 21:37:39 +02:00
2019-02-23 19:06:23 +01:00
def test_leadership_requires_properties_invalid ( ) :
2018-09-29 21:37:39 +02:00
ip_admin = StrOption ( ' ip_admin ' , " ip réseau autorisé " )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' option ' : ip_admin_eth0 , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
2019-02-23 19:06:23 +01:00
raises ( ValueError , " Leadership( ' ip_admin_eth0 ' , ' ' , [ip_admin_eth0, netmask_admin_eth0], properties=( ' disabled ' ,), requires=[ { ' option ' : ip_admin, ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' }]) " )
2018-09-29 21:37:39 +02:00
2019-02-23 19:06:23 +01:00
def test_leadership_requires_properties_invalid_2 ( ) :
2018-09-29 21:37:39 +02:00
ip_admin = StrOption ( ' ip_admin ' , " ip réseau autorisé " )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True ,
requires = [ { ' option ' : ip_admin , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' option ' : ip_admin_eth0 , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
2019-02-23 19:06:23 +01:00
raises ( ValueError , " Leadership( ' ip_admin_eth0 ' , ' ' , [ip_admin_eth0, netmask_admin_eth0], properties=( ' disabled ' ,)) " )
2018-09-29 21:37:39 +02:00
2019-02-23 19:06:23 +01:00
def test_leadership_requires_properties ( ) :
2018-09-29 21:37:39 +02:00
ip_admin = StrOption ( ' ip_admin ' , " ip réseau autorisé " )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' option ' : ip_admin_eth0 , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
2019-02-23 19:06:23 +01:00
Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] , properties = ( ' hidden ' , ) ,
2019-03-13 08:49:18 +01:00
requires = [ { ' option ' : ip_admin , ' expected ' : ' 192.168.1.1 ' , ' action ' : ' disabled ' } ] )
2018-09-29 21:37:39 +02:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_leader ( config_type ) :
2018-09-02 11:55:19 +02:00
activate = BoolOption ( ' activate ' , " Activer l ' accès au réseau " , True )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True ,
requires = [ { ' option ' : activate , ' expected ' : False , ' action ' : ' disabled ' } ] )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True )
2019-02-23 19:06:23 +01:00
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ activate , interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( True )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
assert cfg . value . dict ( ) == { ' activate ' : False }
2018-09-02 11:55:19 +02:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_leader_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
activate = BoolOption ( ' activate ' , " Activer l ' accès au réseau " , True )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( activate ) ) , ' expected ' : False , ' action ' : ' disabled ' } ] )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True )
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ activate , interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( True )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
assert cfg . value . dict ( ) == { ' activate ' : False }
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_leadership ( config_type ) :
2018-09-02 11:55:19 +02:00
activate = BoolOption ( ' activate ' , " Activer l ' accès au réseau " , True )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True )
2019-02-23 19:06:23 +01:00
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] ,
2018-09-02 11:55:19 +02:00
requires = [ { ' option ' : activate , ' expected ' : False , ' action ' : ' disabled ' } ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ activate , interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( True )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
2018-09-02 11:55:19 +02:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
assert cfg . value . dict ( ) == { ' activate ' : False }
2018-09-02 11:55:19 +02:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_leadership_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
activate = BoolOption ( ' activate ' , " Activer l ' accès au réseau " , True )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True )
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( activate ) ) , ' expected ' : False , ' action ' : ' disabled ' } ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ activate , interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( True )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.ip_admin_eth0 ' ).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
assert cfg . value . dict ( ) == { ' activate ' : False }
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_no_leader ( config_type ) :
2015-11-30 15:55:34 +01:00
activate = BoolOption ( ' activate ' , " Activer l ' accès au réseau " , True )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' option ' : activate , ' expected ' : False , ' action ' : ' disabled ' } ] )
2019-02-23 19:06:23 +01:00
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ activate , interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
cfg . option ( ' activate ' ) . value . set ( False )
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] )
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
cfg . option ( ' activate ' ) . value . set ( True )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) is None
cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . set ( ' 255.255.255.255 ' )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) == ' 255.255.255.255 '
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
print ( ' ======================================= ' )
print ( cfg . value . dict ( ) )
print ( { ' ip_admin_eth0.ip_admin_eth0 ' : [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] , ' activate ' : False } )
assert cfg . value . dict ( ) == { ' ip_admin_eth0.ip_admin_eth0 ' : [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] , ' activate ' : False }
def test_leadership_requires_no_leader_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
activate = BoolOption ( ' activate ' , " Activer l ' accès au réseau " , True )
ip_admin_eth0 = StrOption ( ' ip_admin_eth0 ' , " ip réseau autorisé " , multi = True )
netmask_admin_eth0 = StrOption ( ' netmask_admin_eth0 ' , " masque du sous-réseau " , multi = True ,
requires = [ { ' callback ' : calc_value , ' callback_params ' : Params ( ParamOption ( activate ) ) , ' expected ' : False , ' action ' : ' disabled ' } ] )
interface1 = Leadership ( ' ip_admin_eth0 ' , ' ' , [ ip_admin_eth0 , netmask_admin_eth0 ] )
2019-07-04 20:43:47 +02:00
od = OptionDescription ( ' toto ' , ' ' , [ activate , interface1 ] )
cfg = Config ( od )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ]
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' ] )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' ]
cfg . option ( ' activate ' ) . value . set ( False )
cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . set ( [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ] )
assert cfg . option ( ' ip_admin_eth0.ip_admin_eth0 ' ) . value . get ( ) == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
cfg . option ( ' activate ' ) . value . set ( True )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 0 ) . value . get ( ) is None
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) is None
cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . set ( ' 255.255.255.255 ' )
assert cfg . option ( ' ip_admin_eth0.netmask_admin_eth0 ' , 1 ) . value . get ( ) == ' 255.255.255.255 '
cfg . option ( ' activate ' ) . value . set ( False )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 0).value.get() " )
raises ( PropertiesOptionError , " cfg.option( ' ip_admin_eth0.netmask_admin_eth0 ' , 1).value.get() " )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert set ( dico . keys ( ) ) == { ' activate ' , ' ip_admin_eth0.ip_admin_eth0 ' , ' ip_admin_eth0.netmask_admin_eth0 ' }
dico [ ' ip_admin_eth0.ip_admin_eth0 ' ] == [ ' 192.168.1.2 ' , ' 192.168.1.1 ' ]
dico [ ' activate ' ] == False
del dico [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 1 ]
del dico [ ' ip_admin_eth0.netmask_admin_eth0 ' ] [ 0 ]
2019-07-04 20:43:47 +02:00
def test_leadership_requires_complet ( config_type ) :
optiontoto = StrOption ( ' unicodetoto ' , " Unicode " )
2019-03-02 19:43:51 +01:00
option = StrOption ( ' unicode ' , " Unicode leader " , multi = True )
option1 = StrOption ( ' unicode1 ' , " Unicode follower 1 " , multi = True )
option2 = StrOption ( ' unicode2 ' , " Values ' test ' must show ' Unicode follower 3 ' " , multi = True )
option3 = StrOption ( ' unicode3 ' , " Unicode follower 3 " , requires = [ { ' option ' : option ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option4 = StrOption ( ' unicode4 ' , " Unicode follower 4 " , requires = [ { ' option ' : option2 ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option5 = StrOption ( ' unicode5 ' , " Unicode follower 5 " , requires = [ { ' option ' : optiontoto ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option6 = StrOption ( ' unicode6 ' , " Unicode follower 6 " , requires = [ { ' option ' : optiontoto ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ,
{ ' option ' : option2 ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option7 = StrOption ( ' unicode7 ' , " Unicode follower 7 " , requires = [ { ' option ' : option2 ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ,
{ ' option ' : optiontoto ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
descr1 = Leadership ( " unicode " , " Common configuration 1 " ,
[ option , option1 , option2 , option3 , option4 , option5 , option6 , option7 ] )
descr = OptionDescription ( " options " , " Common configuration 2 " , [ descr1 , optiontoto ] )
descr = OptionDescription ( " unicode1_leadership_requires " , " Leader followers with Unicode follower 3 hidden when Unicode follower 2 is test " , [ descr ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( descr )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' options.unicode.unicode ' ) . value . set ( [ ' test ' , ' trah ' ] )
cfg . option ( ' options.unicode.unicode2 ' , 0 ) . value . set ( ' test ' )
dico = cfg . value . dict ( )
2019-03-02 19:43:51 +01:00
assert dico . keys ( ) == set ( [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ] )
assert dico [ ' options.unicode.unicode ' ] == [ ' test ' , ' trah ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ ' test ' , None ]
assert dico [ ' options.unicode.unicode3 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode4 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicodetoto ' ] is None
del dico [ ' options.unicode.unicode3 ' ] [ 1 ]
del dico [ ' options.unicode.unicode3 ' ]
del dico [ ' options.unicode.unicode4 ' ] [ 1 ]
del dico [ ' options.unicode.unicode4 ' ]
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicodetoto ' ) . value . set ( ' test ' )
dico = cfg . value . dict ( )
2019-03-02 19:43:51 +01:00
assert dico . keys ( ) == set ( [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicode.unicode5 ' , ' options.unicode.unicode6 ' , ' options.unicode.unicode7 ' , ' options.unicodetoto ' ] )
assert dico [ ' options.unicode.unicode ' ] == [ ' test ' , ' trah ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ ' test ' , None ]
assert dico [ ' options.unicode.unicode3 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode4 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode5 ' ] == [ None , None ]
assert dico [ ' options.unicode.unicode6 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode6 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode7 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode7 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicodetoto ' ] == ' test '
del dico [ ' options.unicode.unicode3 ' ] [ 1 ]
del dico [ ' options.unicode.unicode3 ' ]
del dico [ ' options.unicode.unicode4 ' ] [ 1 ]
del dico [ ' options.unicode.unicode4 ' ]
del dico [ ' options.unicode.unicode6 ' ] [ 1 ]
del dico [ ' options.unicode.unicode6 ' ]
del dico [ ' options.unicode.unicode7 ' ] [ 1 ]
del dico [ ' options.unicode.unicode7 ' ]
2019-03-03 08:02:57 +01:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_complet_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
optiontoto = StrOption ( ' unicodetoto ' , " Unicode leader " )
option = StrOption ( ' unicode ' , " Unicode leader " , multi = True )
option1 = StrOption ( ' unicode1 ' , " Unicode follower 1 " , multi = True )
option2 = StrOption ( ' unicode2 ' , " Values ' test ' must show ' Unicode follower 3 ' " , multi = True )
option3 = StrOption ( ' unicode3 ' , " Unicode follower 3 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( option ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option4 = StrOption ( ' unicode4 ' , " Unicode follower 4 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( option2 ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option5 = StrOption ( ' unicode5 ' , " Unicode follower 5 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( optiontoto ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option6 = StrOption ( ' unicode6 ' , " Unicode follower 6 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( optiontoto ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ,
{ ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( option2 ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
option7 = StrOption ( ' unicode7 ' , " Unicode follower 7 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( option2 ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ,
{ ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( optiontoto ) ) ,
' expected ' : u ' test ' ,
' action ' : ' hidden ' ,
' inverse ' : True } ] ,
multi = True )
descr1 = Leadership ( " unicode " , " Common configuration 1 " ,
[ option , option1 , option2 , option3 , option4 , option5 , option6 , option7 ] )
descr = OptionDescription ( " options " , " Common configuration 2 " , [ descr1 , optiontoto ] )
descr = OptionDescription ( " unicode1_leadership_requires " , " Leader followers with Unicode follower 3 hidden when Unicode follower 2 is test " , [ descr ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( descr )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
cfg . option ( ' options.unicode.unicode ' ) . value . set ( [ ' test ' , ' trah ' ] )
cfg . option ( ' options.unicode.unicode2 ' , 0 ) . value . set ( ' test ' )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert dico . keys ( ) == set ( [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicode.unicode5 ' , ' options.unicode.unicode6 ' , ' options.unicode.unicode7 ' , ' options.unicodetoto ' ] )
assert dico [ ' options.unicode.unicode ' ] == [ ' test ' , ' trah ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ ' test ' , None ]
assert dico [ ' options.unicode.unicode3 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode4 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicodetoto ' ] is None
del dico [ ' options.unicode.unicode3 ' ] [ 1 ]
del dico [ ' options.unicode.unicode3 ' ]
del dico [ ' options.unicode.unicode4 ' ] [ 1 ]
del dico [ ' options.unicode.unicode4 ' ]
del dico [ ' options.unicode.unicode5 ' ] [ 0 ]
del dico [ ' options.unicode.unicode5 ' ] [ 0 ]
del dico [ ' options.unicode.unicode6 ' ] [ 0 ]
del dico [ ' options.unicode.unicode6 ' ] [ 0 ]
del dico [ ' options.unicode.unicode7 ' ] [ 0 ]
del dico [ ' options.unicode.unicode7 ' ] [ 0 ]
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicodetoto ' ) . value . set ( ' test ' )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert dico . keys ( ) == set ( [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicode.unicode5 ' , ' options.unicode.unicode6 ' , ' options.unicode.unicode7 ' , ' options.unicodetoto ' ] )
assert dico [ ' options.unicode.unicode ' ] == [ ' test ' , ' trah ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ ' test ' , None ]
assert dico [ ' options.unicode.unicode3 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode4 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode5 ' ] == [ None , None ]
assert dico [ ' options.unicode.unicode6 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode6 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode7 ' ] [ 0 ] is None
assert isinstance ( dico [ ' options.unicode.unicode7 ' ] [ 1 ] , PropertiesOptionError )
assert dico [ ' options.unicodetoto ' ] == ' test '
del dico [ ' options.unicode.unicode3 ' ] [ 1 ]
del dico [ ' options.unicode.unicode3 ' ]
del dico [ ' options.unicode.unicode4 ' ] [ 1 ]
del dico [ ' options.unicode.unicode4 ' ]
del dico [ ' options.unicode.unicode6 ' ] [ 1 ]
del dico [ ' options.unicode.unicode6 ' ]
del dico [ ' options.unicode.unicode7 ' ] [ 1 ]
del dico [ ' options.unicode.unicode7 ' ]
2019-07-04 20:43:47 +02:00
def test_leadership_requires_transitive1 ( config_type ) :
optiontoto = StrOption ( ' unicodetoto ' , " Simple unicode " )
2019-03-03 08:02:57 +01:00
option = StrOption ( ' unicode ' , " Unicode leader " , multi = True )
option1 = StrOption ( ' unicode1 ' , " Unicode follower 1 " , multi = True )
option2 = StrOption ( ' unicode2 ' , " Unicode follower 2 " , requires = [ { ' option ' : optiontoto ,
' expected ' : u ' test ' ,
' action ' : ' disabled ' ,
' transitive ' : True ,
' inverse ' : True } ] ,
multi = True )
option3 = StrOption ( ' unicode3 ' , " Unicode follower 3 " , requires = [ { ' option ' : option2 ,
' expected ' : u ' test ' ,
' action ' : ' disabled ' ,
' transitive ' : True ,
' inverse ' : True } ] ,
multi = True )
option4 = StrOption ( ' unicode4 ' , " Unicode follower 4 " , requires = [ { ' option ' : option3 ,
' expected ' : u ' test ' ,
' action ' : ' disabled ' ,
' transitive ' : True ,
' inverse ' : True } ] ,
multi = True )
descr1 = Leadership ( " unicode " , " Common configuration 1 " ,
[ option , option1 , option2 , option3 , option4 ] )
descr = OptionDescription ( " options " , " Common configuration 2 " , [ descr1 , optiontoto ] )
descr = OptionDescription ( " unicode1 " , " " , [ descr ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( descr )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . value . dict ( ) == { ' options.unicode.unicode ' : [ ] , ' options.unicode.unicode1 ' : [ ] , ' options.unicode.unicode3 ' : [ ] , ' options.unicode.unicode4 ' : [ ] , ' options.unicodetoto ' : None }
2019-03-03 08:02:57 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicodetoto ' ) . value . set ( ' test ' )
assert cfg . value . dict ( ) == { ' options.unicode.unicode ' : [ ] , ' options.unicode.unicode1 ' : [ ] , ' options.unicode.unicode2 ' : [ ] , ' options.unicode.unicode3 ' : [ ] , ' options.unicode.unicode4 ' : [ ] , ' options.unicodetoto ' : ' test ' }
2019-03-03 08:02:57 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode ' ) . value . set ( [ ' a ' , ' b ' , ' c ' ] )
dico = cfg . value . dict ( )
2019-03-03 08:02:57 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' test '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ None , None , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode2 ' , 1 ) . value . set ( ' test ' )
cfg . option ( ' options.unicode.unicode3 ' , 1 ) . value . set ( ' test ' )
dico = cfg . value . dict ( )
2019-03-03 08:02:57 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' test '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ None , ' test ' , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode3 ' ] [ 1 ] == ' test '
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode4 ' ] [ 1 ] == None
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode2 ' , 1 ) . value . set ( ' rah ' )
dico = cfg . value . dict ( )
2019-03-03 08:02:57 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' test '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ None , ' rah ' , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode2 ' , 1 ) . value . set ( ' test ' )
cfg . option ( ' options.unicodetoto ' ) . value . set ( ' rah ' )
dico = cfg . value . dict ( )
2019-03-03 08:02:57 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' rah '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
2019-03-13 08:49:18 +01:00
2019-07-04 20:43:47 +02:00
def test_leadership_requires_transitive_callback ( config_type ) :
2019-03-13 08:49:18 +01:00
optiontoto = StrOption ( ' unicodetoto ' , " Unicode leader " )
option = StrOption ( ' unicode ' , " Unicode leader " , multi = True )
option1 = StrOption ( ' unicode1 ' , " Unicode follower 1 " , multi = True )
option2 = StrOption ( ' unicode2 ' , " Unicode follower 2 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( optiontoto ) ) ,
' expected ' : u ' test ' ,
' action ' : ' disabled ' ,
' transitive ' : True ,
' inverse ' : True } ] ,
multi = True )
option3 = StrOption ( ' unicode3 ' , " Unicode follower 3 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( option2 ) ) ,
' expected ' : u ' test ' ,
' action ' : ' disabled ' ,
' transitive ' : True ,
' inverse ' : True } ] ,
multi = True )
option4 = StrOption ( ' unicode4 ' , " Unicode follower 4 " , requires = [ { ' callback ' : calc_value ,
' callback_params ' : Params ( ParamOption ( option3 ) ) ,
' expected ' : u ' test ' ,
' action ' : ' disabled ' ,
' transitive ' : True ,
' inverse ' : True } ] ,
multi = True )
descr1 = Leadership ( " unicode " , " Common configuration 1 " ,
[ option , option1 , option2 , option3 , option4 ] )
descr = OptionDescription ( " options " , " Common configuration 2 " , [ descr1 , optiontoto ] )
descr = OptionDescription ( " unicode1 " , " " , [ descr ] )
2019-07-04 20:43:47 +02:00
cfg = Config ( descr )
cfg . property . read_write ( )
cfg = get_config ( cfg , config_type )
assert cfg . value . dict ( ) == { ' options.unicode.unicode ' : [ ] , ' options.unicode.unicode1 ' : [ ] , ' options.unicode.unicode2 ' : [ ] , ' options.unicode.unicode3 ' : [ ] , ' options.unicode.unicode4 ' : [ ] , ' options.unicodetoto ' : None }
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicodetoto ' ) . value . set ( ' test ' )
assert cfg . value . dict ( ) == { ' options.unicode.unicode ' : [ ] , ' options.unicode.unicode1 ' : [ ] , ' options.unicode.unicode2 ' : [ ] , ' options.unicode.unicode3 ' : [ ] , ' options.unicode.unicode4 ' : [ ] , ' options.unicodetoto ' : ' test ' }
2019-03-13 08:49:18 +01:00
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode ' ) . value . set ( [ ' a ' , ' b ' , ' c ' ] )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' test '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ None , None , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode2 ' , 1 ) . value . set ( ' test ' )
cfg . option ( ' options.unicode.unicode3 ' , 1 ) . value . set ( ' test ' )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' test '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ None , ' test ' , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode3 ' ] [ 1 ] == ' test '
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert dico [ ' options.unicode.unicode4 ' ] [ 1 ] == None
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode2 ' , 1 ) . value . set ( ' rah ' )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' test '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert dico [ ' options.unicode.unicode2 ' ] == [ None , ' rah ' , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )
#
2019-07-04 20:43:47 +02:00
cfg . option ( ' options.unicode.unicode2 ' , 1 ) . value . set ( ' test ' )
cfg . option ( ' options.unicodetoto ' ) . value . set ( ' rah ' )
dico = cfg . value . dict ( )
2019-03-13 08:49:18 +01:00
assert list ( dico . keys ( ) ) == [ ' options.unicode.unicode ' , ' options.unicode.unicode1 ' , ' options.unicode.unicode2 ' , ' options.unicode.unicode3 ' , ' options.unicode.unicode4 ' , ' options.unicodetoto ' ]
assert dico [ ' options.unicodetoto ' ] == ' rah '
assert dico [ ' options.unicode.unicode ' ] == [ ' a ' , ' b ' , ' c ' ]
assert dico [ ' options.unicode.unicode1 ' ] == [ None , None , None ]
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] , PropertiesOptionError )
assert isinstance ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] , PropertiesOptionError )
del ( dico [ ' options.unicode.unicode2 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode2 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode2 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode3 ' ] [ 0 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 2 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 1 ] )
del ( dico [ ' options.unicode.unicode4 ' ] [ 0 ] )