add test_properties

This commit is contained in:
Emmanuel Garette 2018-04-05 19:06:38 +02:00
parent 4ee9cc82b2
commit cf3e8cded9

View File

@ -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', '',