From beb615e707b8027d13acb796c5cc6bc2370f8a49 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 4 Aug 2018 23:08:02 +0200 Subject: [PATCH] add inverse test --- test/test_requires.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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'}])