remove _setoption in SymLinkOption
objimpl_ => optimpl_ ConflictConfigError => ConflictError add read_write/read_only/getowner in Config
This commit is contained in:
@ -22,25 +22,23 @@ def make_description():
|
||||
def test_mandatory_ro():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.str1
|
||||
except PropertiesOptionError, err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str1 = 'yes'
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
assert config.str1 == 'yes'
|
||||
|
||||
|
||||
def test_mandatory_rw():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
#not mandatory in rw
|
||||
config.str1
|
||||
config.str1 = 'yes'
|
||||
@ -50,17 +48,16 @@ def test_mandatory_rw():
|
||||
def test_mandatory_default():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
#not mandatory in rw
|
||||
config.str
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str = 'yes'
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
config.str
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str = None
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.str
|
||||
@ -74,9 +71,8 @@ def test_mandatory_none():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.str1 = None
|
||||
setting = config.cfgimpl_get_settings()
|
||||
assert config.cfgimpl_get_values().getowner(descr.str1) == 'user'
|
||||
setting.read_only()
|
||||
assert config.getowner('str1') == 'user'
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.str1
|
||||
@ -89,9 +85,8 @@ def test_mandatory_empty():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.str1 = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
assert config.cfgimpl_get_values().getowner(descr.str1) == 'user'
|
||||
setting.read_only()
|
||||
assert config.getowner('str1') == 'user'
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.str1
|
||||
@ -103,20 +98,19 @@ def test_mandatory_empty():
|
||||
def test_mandatory_multi_none():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.str3 = [None]
|
||||
setting.read_only()
|
||||
assert config.cfgimpl_get_values().getowner(descr.str3) == 'user'
|
||||
config.read_only()
|
||||
assert config.getowner('str3') == 'user'
|
||||
prop = []
|
||||
try:
|
||||
config.str3
|
||||
except PropertiesOptionError, err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str3 = ['yes', None]
|
||||
setting.read_only()
|
||||
assert config.cfgimpl_get_values().getowner(descr.str3) == 'user'
|
||||
config.read_only()
|
||||
assert config.getowner('str3') == 'user'
|
||||
prop = []
|
||||
try:
|
||||
config.str3
|
||||
@ -128,20 +122,19 @@ def test_mandatory_multi_none():
|
||||
def test_mandatory_multi_empty():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.str3 = ['']
|
||||
setting.read_only()
|
||||
assert config.cfgimpl_get_values().getowner(descr.str3) == 'user'
|
||||
config.read_only()
|
||||
assert config.getowner('str3') == 'user'
|
||||
prop = []
|
||||
try:
|
||||
config.str3
|
||||
except PropertiesOptionError, err:
|
||||
prop = err.proptype
|
||||
assert 'mandatory' in prop
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str3 = ['yes', '']
|
||||
setting.read_only()
|
||||
assert config.cfgimpl_get_values().getowner(descr.str3) == 'user'
|
||||
config.read_only()
|
||||
assert config.getowner('str3') == 'user'
|
||||
prop = []
|
||||
try:
|
||||
config.str3
|
||||
@ -153,9 +146,8 @@ def test_mandatory_multi_empty():
|
||||
def test_mandatory_multi_append():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.str3 = ['yes']
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str3.append(None)
|
||||
|
||||
|
||||
@ -164,7 +156,7 @@ def test_mandatory_disabled():
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.str1
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.str1
|
||||
@ -183,18 +175,17 @@ def test_mandatory_disabled():
|
||||
def test_mandatory_unicode():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
setting = config.cfgimpl_get_settings()
|
||||
config.unicode2
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.unicode2
|
||||
except PropertiesOptionError, err:
|
||||
prop = err.proptype
|
||||
assert prop == ['mandatory']
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.unicode2 = u''
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
prop = []
|
||||
try:
|
||||
config.unicode2
|
||||
@ -207,8 +198,7 @@ def test_mandatory_warnings_ro():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
proc = []
|
||||
try:
|
||||
config.str
|
||||
@ -216,9 +206,9 @@ def test_mandatory_warnings_ro():
|
||||
proc = err.proptype
|
||||
assert proc == ['mandatory']
|
||||
assert list(mandatory_warnings(config)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str = 'a'
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
assert list(mandatory_warnings(config)) == ['str1', 'unicode2', 'str3']
|
||||
|
||||
|
||||
@ -226,8 +216,7 @@ def test_mandatory_warnings_rw():
|
||||
descr = make_description()
|
||||
config = Config(descr)
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str
|
||||
assert list(mandatory_warnings(config)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
config.str = 'a'
|
||||
@ -239,7 +228,7 @@ def test_mandatory_warnings_disabled():
|
||||
config = Config(descr)
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str
|
||||
assert list(mandatory_warnings(config)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
setting[descr.str].append('disabled')
|
||||
@ -251,9 +240,9 @@ def test_mandatory_warnings_frozen():
|
||||
config = Config(descr)
|
||||
config.str = ''
|
||||
setting = config.cfgimpl_get_settings()
|
||||
setting.read_write()
|
||||
config.read_write()
|
||||
config.str
|
||||
assert list(mandatory_warnings(config)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
setting[descr.str].append('frozen')
|
||||
setting.read_only()
|
||||
config.read_only()
|
||||
assert list(mandatory_warnings(config)) == ['str', 'str1', 'unicode2', 'str3']
|
||||
|
Reference in New Issue
Block a user