cannot set properties if those properties are in requirement
This commit is contained in:
@ -112,6 +112,40 @@ def test_multiple_requires_cumulative():
|
||||
c.ip_address_service
|
||||
|
||||
|
||||
def test_multiple_requires_cumulative_inverse():
|
||||
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])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
props = []
|
||||
try:
|
||||
c.ip_address_service
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert set(props) == set(['hidden', 'disabled'])
|
||||
c.activate_service = 'yes'
|
||||
c.ip_address_service
|
||||
|
||||
c.activate_service = 'ok'
|
||||
props = []
|
||||
try:
|
||||
c.ip_address_service
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert set(props) == set(['hidden', 'disabled'])
|
||||
|
||||
c.activate_service = 'no'
|
||||
props = []
|
||||
try:
|
||||
c.ip_address_service
|
||||
except PropertiesOptionError as err:
|
||||
props = err.proptype
|
||||
assert set(props) == set(['hidden', 'disabled'])
|
||||
|
||||
|
||||
def test_multiple_requires_inverse():
|
||||
a = StrOption('activate_service', '')
|
||||
b = IPOption('ip_address_service', '',
|
||||
@ -500,3 +534,9 @@ def test_set_item():
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
raises(ValueError, 'c.cfgimpl_get_settings()[a] = ("test",)')
|
||||
|
||||
|
||||
def test_properties_conflict():
|
||||
a = BoolOption('activate_service', '', True)
|
||||
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'}])")
|
||||
|
@ -107,7 +107,7 @@ def test_slots_option_readonly_name():
|
||||
|
||||
|
||||
def test_slots_description():
|
||||
# __slots__ for OptionDescription must be complete
|
||||
# __slots__ for OptionDescription should be complete for __getattr__
|
||||
slots = set()
|
||||
for subclass in OptionDescription.__mro__:
|
||||
if subclass is not object:
|
||||
|
Reference in New Issue
Block a user