tiramisu/test/test_permissive.py

84 lines
2.2 KiB
Python
Raw Normal View History

# coding: utf-8
import autopath
from tiramisu.option import IntOption, OptionDescription
from tiramisu.config import Config
from tiramisu.error import PropertiesOptionError
def make_description():
u1 = IntOption('u1', '', properties=('frozen', 'mandatory', 'disabled', ))
return OptionDescription('od1', '', [u1])
def test_permissive():
descr = make_description()
config = Config(descr)
setting = config.cfgimpl_get_settings()
setting.read_write()
props = []
try:
config.u1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled']
setting.set_permissive(('disabled',))
props = []
try:
config.u1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled']
setting.append('permissive')
config.u1
setting.remove('permissive')
props = []
try:
config.u1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled']
def test_permissive_mandatory():
descr = make_description()
config = Config(descr)
setting = config.cfgimpl_get_settings()
setting.read_only()
props = []
try:
config.u1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled', 'mandatory']
setting.set_permissive(('mandatory', 'disabled',))
setting.append('permissive')
config.u1
setting.remove('permissive')
try:
config.u1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled', 'mandatory']
def test_permissive_frozen():
descr = make_description()
config = Config(descr)
setting = config.cfgimpl_get_settings()
setting.read_write()
setting.set_permissive(('frozen', 'disabled',))
try:
config.u1 = 1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled', 'frozen']
setting.append('permissive')
config.u1 = 1
assert config.u1 == 1
setting.remove('permissive')
try:
config.u1 = 1
except PropertiesOptionError, err:
props = err.proptype
assert props == ['disabled', 'frozen']