for a multi mandatory, allow [] with allow_empty_list attribut

This commit is contained in:
2015-04-20 14:49:43 +02:00
parent 072246a203
commit 487b99b32c
6 changed files with 73 additions and 14 deletions

View File

@ -16,7 +16,9 @@ def make_description():
properties=('mandatory', ))
stroption3 = StrOption('str3', 'Test string option', multi=True,
properties=('mandatory', ))
descr = OptionDescription('tiram', '', [stroption, stroption1, stroption2, stroption3])
stroption4 = StrOption('str4', 'Test string option', multi=True,
properties=('mandatory', ), allow_empty_list=True)
descr = OptionDescription('tiram', '', [stroption, stroption1, stroption2, stroption3, stroption4])
return descr
@ -123,6 +125,17 @@ def test_mandatory_multi_none():
def test_mandatory_multi_empty():
descr = make_description()
config = Config(descr)
config.str3 = []
assert config.getowner(config.unwrap_from_path('str3')) == 'user'
config.read_only()
prop = []
try:
config.str3
except PropertiesOptionError as err:
prop = err.proptype
assert 'mandatory' in prop
#
config.read_write()
config.str3 = ['']
assert config.getowner(config.unwrap_from_path('str3')) == 'user'
config.read_only()
@ -132,6 +145,7 @@ def test_mandatory_multi_empty():
except PropertiesOptionError as err:
prop = err.proptype
assert 'mandatory' in prop
#
config.read_write()
config.str3 = ['yes', '']
assert config.getowner(config.unwrap_from_path('str3')) == 'user'
@ -144,6 +158,38 @@ def test_mandatory_multi_empty():
assert 'mandatory' in prop
def test_mandatory_multi_empty_allow_empty_list():
descr = make_description()
config = Config(descr)
config.str4 = []
assert config.getowner(config.unwrap_from_path('str4')) == 'user'
config.read_only()
prop = []
config.str4
#
config.read_write()
config.str4 = ['']
assert config.getowner(config.unwrap_from_path('str4')) == 'user'
config.read_only()
prop = []
try:
config.str4
except PropertiesOptionError as err:
prop = err.proptype
assert 'mandatory' in prop
#
config.read_write()
config.str4 = ['yes', '']
assert config.getowner(config.unwrap_from_path('str4')) == 'user'
config.read_only()
prop = []
try:
config.str4
except PropertiesOptionError as err:
prop = err.proptype
assert 'mandatory' in prop
def test_mandatory_multi_append():
descr = make_description()
config = Config(descr)