replace special_owner with hascallback_and_freeze
This commit is contained in:
@ -3,7 +3,6 @@ import autopath
|
||||
from py.test import raises
|
||||
from tiramisu.config import *
|
||||
from tiramisu.option import *
|
||||
from tiramisu.error import SpecialOwnersError
|
||||
|
||||
def make_description():
|
||||
gcoption = ChoiceOption('name', 'GC name', ['ref', 'framework'], 'ref')
|
||||
@ -67,65 +66,20 @@ def test_override_are_default_owner():
|
||||
config.gc.dummy = False
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
|
||||
def test_change_owner():
|
||||
def test_has_callback():
|
||||
descr = make_description()
|
||||
# here the owner is 'default'
|
||||
config = Config(descr, bool=False)
|
||||
# the default owner is 'user' (which is not 'default')
|
||||
# Still not getting it ? read the docs
|
||||
config.gc.dummy = True
|
||||
assert config.gc._cfgimpl_value_owners['dummy'] == 'user'
|
||||
# config.cfgimpl_set_owner('eggs')
|
||||
# config.set(dummy=False)
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'eggs'
|
||||
# config.cfgimpl_set_owner('spam')
|
||||
# gcdummy = config.unwrap_from_path('gc.dummy')
|
||||
# gcdummy.setowner(config.gc, 'blabla')
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'blabla'
|
||||
# config.gc.dummy = True
|
||||
# assert config.gc._cfgimpl_value_owners['dummy'] == 'spam'
|
||||
|
||||
# because dummy has a callback
|
||||
raises(ConflictConfigError, "config.gc.dummy = True")
|
||||
#____________________________________________________________
|
||||
# special owners
|
||||
def test_auto_owner():
|
||||
def test_has_callback_with_setoption():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config.gc.setoption('dummy', True, 'auto')
|
||||
raises(PropertiesOptionError, "config.gc.dummy")
|
||||
raises(ConflictConfigError, "config.gc.setoption('dummy', False, 'auto')")
|
||||
# shall return an auto value...
|
||||
#assert config.gc.dummy == 'auto_dummy_value'
|
||||
raises(ConflictConfigError, "config.gc.setoption('dummy', True, 'gen_config')")
|
||||
|
||||
def test_cannot_override_special_owners():
|
||||
descr = make_description()
|
||||
config = Config(descr, bool=False)
|
||||
config.gc.setoption('dummy', True, 'auto')
|
||||
raises(SpecialOwnersError, "config.override({'gc.dummy': True})")
|
||||
|
||||
# FIXME have to test the fills anyway
|
||||
#def test_fill_owner():
|
||||
# "fill option"
|
||||
# descr = make_description()
|
||||
# config = Config(descr, bool=False)
|
||||
# assert config.bool == False
|
||||
# assert config.gc.dummy == False
|
||||
# # 'fill' special values
|
||||
# config.gc.setoption('dummy', True, 'fill')
|
||||
# assert config.gc.dummy == False
|
||||
|
||||
#def test_auto_fill_and_override():
|
||||
# descr = make_description()
|
||||
# config = Config(descr, bool=False)
|
||||
# booloption = config.unwrap_from_path('bool')
|
||||
# booloption.callback = 'identical'
|
||||
# booloption.setowner(config, 'auto')
|
||||
# assert config.bool == 'identicalbool'
|
||||
# gcdummy = config.unwrap_from_path('gc.dummy')
|
||||
# gcdummy.callback = 'identical'
|
||||
# gcdummy.setowner(config.gc, 'fill')
|
||||
# raises(SpecialOwnersError, "config.override({'gc.dummy':True})")
|
||||
# config.gc.setoption('dummy', False, 'fill')
|
||||
# # value is returned
|
||||
# assert config.gc.dummy == False
|
||||
|
||||
raises(ConflictConfigError, "config.override({'gc.dummy': True})")
|
||||
|
||||
|
@ -67,7 +67,7 @@ def test_freeze_one_option():
|
||||
#freeze only one option
|
||||
conf.gc._cfgimpl_descr.dummy.freeze()
|
||||
assert conf.gc.dummy == False
|
||||
raises(TypeError, "conf.gc.dummy = True")
|
||||
raises(ConflictConfigError, "conf.gc.dummy = True")
|
||||
|
||||
def test_frozen_value():
|
||||
"setattr a frozen value at the config level"
|
||||
|
Reference in New Issue
Block a user