diff --git a/test/test_requires.py b/test/test_requires.py index 811f59d..1113b53 100644 --- a/test/test_requires.py +++ b/test/test_requires.py @@ -58,6 +58,29 @@ def test_requires(): 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(): a = StrOption('ip_address_service', '', requires=[{'option': 'self', 'expected': 'b', 'action': 'disabled'}])