tiramisu/test/test_slots.py

66 lines
2 KiB
Python
Raw Normal View History

# coding: utf-8
import autopath
from py.test import raises
from tiramisu.config import Config, SubConfig
from tiramisu.option import ChoiceOption, BoolOption, IntOption, FloatOption, \
2013-08-30 09:40:28 +02:00
StrOption, SymLinkOption, UnicodeOption, IPOption, OptionDescription, \
PortOption, NetworkOption, NetmaskOption, DomainnameOption
def test_slots_option():
2013-08-30 09:40:28 +02:00
c = ChoiceOption('a', '', ('a',))
raises(AttributeError, "c.x = 1")
c = BoolOption('a', '')
raises(AttributeError, "c.x = 1")
c = IntOption('a', '')
raises(AttributeError, "c.x = 1")
c = FloatOption('a', '')
raises(AttributeError, "c.x = 1")
c = StrOption('a', '')
raises(AttributeError, "c.x = 1")
c = SymLinkOption('b', c)
raises(AttributeError, "c.x = 1")
c = UnicodeOption('a', '')
raises(AttributeError, "c.x = 1")
2013-08-30 09:40:28 +02:00
c = IPOption('a', '')
raises(AttributeError, "c.x = 1")
c = OptionDescription('a', '', [])
raises(AttributeError, "c.x = 1")
2013-08-30 09:40:28 +02:00
c = PortOption('a', '')
raises(AttributeError, "c.x = 1")
c = NetworkOption('a', '')
raises(AttributeError, "c.x = 1")
c = NetmaskOption('a', '')
raises(AttributeError, "c.x = 1")
c = DomainnameOption('a', '')
raises(AttributeError, "c.x = 1")
def test_slots_config():
od1 = OptionDescription('a', '', [])
od2 = OptionDescription('a', '', [od1])
c = Config(od2)
raises(AttributeError, "c.x = 1")
raises(AttributeError, "c.cfgimpl_x = 1")
sc = c.a
assert isinstance(sc, SubConfig)
raises(AttributeError, "sc.x = 1")
raises(AttributeError, "sc.cfgimpl_x = 1")
def test_slots_setting():
od1 = OptionDescription('a', '', [])
od2 = OptionDescription('a', '', [od1])
c = Config(od2)
s = c.cfgimpl_get_settings()
raises(AttributeError, "s.x = 1")
def test_slots_value():
od1 = OptionDescription('a', '', [])
od2 = OptionDescription('a', '', [od1])
c = Config(od2)
v = c.cfgimpl_get_values()
raises(AttributeError, "v.x = 1")