|
|
|
@ -329,11 +329,11 @@ def test_mandatory_warnings_ro():
|
|
|
|
|
except PropertiesOptionError as err:
|
|
|
|
|
prop = err.proptype
|
|
|
|
|
assert 'mandatory' in prop
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'unicode2', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'unicode2', 'str3']
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.set('a')
|
|
|
|
|
api.property.read_only()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str1', 'unicode2', 'str3']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_rw():
|
|
|
|
@ -342,9 +342,9 @@ def test_mandatory_warnings_rw():
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.get()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'unicode2', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'unicode2', 'str3']
|
|
|
|
|
api.option('str').value.set('a')
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str1', 'unicode2', 'str3']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_disabled():
|
|
|
|
@ -353,9 +353,9 @@ def test_mandatory_warnings_disabled():
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.get()
|
|
|
|
|
assert set(api.value.mandatory_warnings()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
assert set(api.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
api.option('str').property.add('disabled')
|
|
|
|
|
assert set(api.value.mandatory_warnings()) == {'str1', 'unicode2', 'str3'}
|
|
|
|
|
assert set(api.value.mandatory()) == {'str1', 'unicode2', 'str3'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_hidden():
|
|
|
|
@ -365,9 +365,9 @@ def test_mandatory_warnings_hidden():
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.permissive.set(frozenset(['hidden']))
|
|
|
|
|
api.option('str').value.get()
|
|
|
|
|
assert set(api.value.mandatory_warnings()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
assert set(api.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
api.option('str').property.add('hidden')
|
|
|
|
|
assert set(api.value.mandatory_warnings()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
assert set(api.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_frozen():
|
|
|
|
@ -376,10 +376,10 @@ def test_mandatory_warnings_frozen():
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.get()
|
|
|
|
|
assert set(api.value.mandatory_warnings()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
assert set(api.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
api.option('str').property.add('frozen')
|
|
|
|
|
api.property.read_only()
|
|
|
|
|
assert set(api.value.mandatory_warnings()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
assert set(api.value.mandatory()) == {'str', 'str1', 'unicode2', 'str3'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_master():
|
|
|
|
@ -404,7 +404,7 @@ def test_mandatory_warnings_master():
|
|
|
|
|
#interface1.impl_set_group_type(groups.master)
|
|
|
|
|
descr = OptionDescription('o', '', [interface1])
|
|
|
|
|
api = Config(descr)
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['ip_admin_eth0.ip_admin_eth0']
|
|
|
|
|
assert list(api.value.mandatory()) == ['ip_admin_eth0.ip_admin_eth0']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_master_empty():
|
|
|
|
@ -462,17 +462,17 @@ def test_mandatory_warnings_master_empty():
|
|
|
|
|
api.option('ip_admin_eth0.ip_admin_eth0').value.set([undefined])
|
|
|
|
|
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == [None]
|
|
|
|
|
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['ip_admin_eth0.ip_admin_eth0']
|
|
|
|
|
assert list(api.value.mandatory()) == ['ip_admin_eth0.ip_admin_eth0']
|
|
|
|
|
api.option('ip_admin_eth0.ip_admin_eth0').value.reset()
|
|
|
|
|
#
|
|
|
|
|
api.option('ip_admin_eth0.ip_admin_eth0').value.set([''])
|
|
|
|
|
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['']
|
|
|
|
|
assert api.option('ip_admin_eth0.netmask_admin_eth0', 0).value.get() == None
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['ip_admin_eth0.ip_admin_eth0']
|
|
|
|
|
assert list(api.value.mandatory()) == ['ip_admin_eth0.ip_admin_eth0']
|
|
|
|
|
#
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['ip'])
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == []
|
|
|
|
|
assert list(api.value.mandatory()) == []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_slave():
|
|
|
|
@ -517,9 +517,9 @@ def test_mandatory_warnings_slave():
|
|
|
|
|
assert api.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
|
|
|
|
#
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == []
|
|
|
|
|
assert list(api.value.mandatory()) == []
|
|
|
|
|
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['ip'])
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['ip_admin_eth0.netmask_admin_eth0']
|
|
|
|
|
assert list(api.value.mandatory()) == ['ip_admin_eth0.netmask_admin_eth0']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_symlink():
|
|
|
|
@ -528,19 +528,19 @@ def test_mandatory_warnings_symlink():
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.get()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'str3']
|
|
|
|
|
api.option('str').property.add('frozen')
|
|
|
|
|
api.property.read_only()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'str3']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#def test_mandatory_warnings_validate():
|
|
|
|
|
# descr = make_description3()
|
|
|
|
|
# api = Config(descr)
|
|
|
|
|
# api.option('str').value.set('')
|
|
|
|
|
# raises(ValueError, "list(api.value.mandatory_warnings())")
|
|
|
|
|
# raises(ValueError, "list(api.value.mandatory())")
|
|
|
|
|
# api.option('str').value.set('test')
|
|
|
|
|
# raises(ValueError, "list(api.value.mandatory_warnings())")
|
|
|
|
|
# raises(ValueError, "list(api.value.mandatory())")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_validate_empty():
|
|
|
|
@ -548,7 +548,7 @@ def test_mandatory_warnings_validate_empty():
|
|
|
|
|
api = Config(descr)
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.property.read_only()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'str3', 'unicode1']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'str3', 'unicode1']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_requires():
|
|
|
|
@ -564,12 +564,12 @@ def test_mandatory_warnings_requires():
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.get()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'unicode2']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'unicode2']
|
|
|
|
|
api.property.read_only()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str', 'str1', 'unicode2']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str', 'str1', 'unicode2']
|
|
|
|
|
api.property.read_write()
|
|
|
|
|
api.option('str').value.set('yes')
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str1', 'unicode2', 'str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str1', 'unicode2', 'str3']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_requires_masterslaves():
|
|
|
|
@ -582,9 +582,9 @@ def test_mandatory_warnings_requires_masterslaves():
|
|
|
|
|
api = Config(descr)
|
|
|
|
|
api.option('str').value.set('')
|
|
|
|
|
api.option('master.str1').value.set(['str'])
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['str']
|
|
|
|
|
assert list(api.value.mandatory()) == ['str']
|
|
|
|
|
api.option('str').value.set('yes')
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['master.str2']
|
|
|
|
|
assert list(api.value.mandatory()) == ['master.str2']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_warnings_requires_masterslaves_slave():
|
|
|
|
@ -595,9 +595,9 @@ def test_mandatory_warnings_requires_masterslaves_slave():
|
|
|
|
|
descr = OptionDescription('tiram', '', [masterslave])
|
|
|
|
|
api = Config(descr)
|
|
|
|
|
api.option('master.str').value.set(['str'])
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == []
|
|
|
|
|
assert list(api.value.mandatory()) == []
|
|
|
|
|
api.option('master.str1', 0).value.set('yes')
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['master.str2']
|
|
|
|
|
assert list(api.value.mandatory()) == ['master.str2']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_mandatory_od_disabled():
|
|
|
|
@ -605,6 +605,6 @@ def test_mandatory_od_disabled():
|
|
|
|
|
descr = OptionDescription('od', '', [descr])
|
|
|
|
|
api = Config(descr)
|
|
|
|
|
api.property.read_only()
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == ['tiram.str1', 'tiram.unicode2', 'tiram.str3']
|
|
|
|
|
assert list(api.value.mandatory()) == ['tiram.str1', 'tiram.unicode2', 'tiram.str3']
|
|
|
|
|
api.option('tiram').property.add('disabled')
|
|
|
|
|
assert list(api.value.mandatory_warnings()) == []
|
|
|
|
|
assert list(api.value.mandatory()) == []
|
|
|
|
|