add inverse test

This commit is contained in:
Emmanuel Garette 2018-08-04 23:08:02 +02:00
parent 8e3b9f2d85
commit beb615e707
1 changed files with 23 additions and 0 deletions

View File

@ -58,6 +58,29 @@ def test_requires():
api.option('ip_address_service').value.get() api.option('ip_address_service').value.get()
def test_requires_inverse():
a = BoolOption('activate_service', '', True)
b = IPOption('ip_address_service', '',
requires=[{'option': a, 'expected': False, 'action': 'disabled', 'inverse': True}])
od = OptionDescription('service', '', [a, b])
api = getapi(Config(od))
api.property.read_write()
props = []
try:
api.option('ip_address_service').value.get()
except PropertiesOptionError as err:
props = err.proptype
assert frozenset(props) == frozenset(['disabled'])
api.option('activate_service').value.set(False)
api.option('ip_address_service').value.get()
api.option('activate_service').value.set(True)
try:
api.option('ip_address_service').value.get()
except PropertiesOptionError as err:
props = err.proptype
assert frozenset(props) == frozenset(['disabled'])
def test_requires_self(): def test_requires_self():
a = StrOption('ip_address_service', '', a = StrOption('ip_address_service', '',
requires=[{'option': 'self', 'expected': 'b', 'action': 'disabled'}]) requires=[{'option': 'self', 'expected': 'b', 'action': 'disabled'}])