From cf3e8cded957b48ec26fd7d384adedcd97ece42f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 5 Apr 2018 19:06:38 +0200 Subject: [PATCH] add test_properties --- test/test_requires.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test_requires.py b/test/test_requires.py index 59b7939..9634cd4 100644 --- a/test/test_requires.py +++ b/test/test_requires.py @@ -12,6 +12,32 @@ from tiramisu.error import PropertiesOptionError, RequirementError from py.test import raises +def test_properties(): + a = BoolOption('activate_service', '', True) + b = IPOption('ip_address_service', '', properties=('disabled',)) + 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('ip_address_service').property.pop('disabled') + api.option('ip_address_service').value.get() + api.option('ip_address_service').property.add('disabled') + props = [] + try: + api.option('ip_address_service').value.get() + except PropertiesOptionError as err: + props = err.proptype + assert frozenset(props) == frozenset(['disabled']) + # pop twice + api.option('ip_address_service').property.pop('disabled') + api.option('ip_address_service').property.pop('disabled') + + def test_requires(): a = BoolOption('activate_service', '', True) b = IPOption('ip_address_service', '',